Tech C**P
15 subscribers
161 photos
9 videos
59 files
304 links
مدرس و برنامه نویس پایتون و لینوکس @alirezastack
Download Telegram
How to implement email tracking solution?

nginX has a module called empty_gif that generates a 1*1 pixel image. It is usually put at the end of campaign emails in order to track how many users have opened the email. The code for nginX is:

location = /empty.gif {
empty_gif;
expires -1;
post_action @track;
}

location @track {
internal;
proxy_pass http://tracking-backend/track$is_args$args;
proxy_set_header x-ip $remote_addr;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
}


The above code check if /empty.gif URL is requested, if answer is yes then serve the image and makes expires to -1 to not cache the image and finally using post_action which calls a sub request after the current request has been fininshed. The parameters you need to pass is put after the image link in email like:

https://www.example.com/empty.gif?token=SOMETHING_TO_TRACK
#nginx #email #empty_gif #email_tracking #pixel