I have seen the service like spypig.com placing a small image in the email and tracking when it is opened and from where. They track city, country, IP address etc. How is this done?
- How do we know when the mail is opened? And how is the image generated?
- How is the IP address detected and how is it possible to know location from it?
Basically, in the HTML body of your email, there will be an
<img>
tag that would look like this :When someone reads his mail, with images enabled, the email-client will send a request to
tracker.php
, to load the image, passing itid=123456
as a parameter.This
tracker.php
script will be on your server, and, when called, it will :id
parameter,id
different for each e-mail.The
tracker.php
script knows from which IP address it's been called -- like any other PHP script :And, starting from this IP address, you can use a geolocation service to find out from where in the world the email has been opened.
As a couple of examples, you could take a look at MaxMind, or IPInfoDB
As you know that
id=123456
corresponds to one specific email address, this allows to find out where each one of your subscribers are.