How to implement email tracking solution?
The above code check if
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