I mentioned in a previous
blog post about monitoring visitors that it is essential to use tracking pixels or tracking images to gather information about who is opening email that you send.
Even the smallest campaign can benefit from this method, and here is an extremely simple script that you can use to implement a basic image tracking program. It logs to a file that you can later reference to see who is opening your emails.
//variables that you must enter
$logFile = "openLOG.txt";
$imageFile = "something.gif";
//This part serves the picture requested
//If your picture is a jpg, change to image/jpeg
header('Content-type: image/gif');
readfile('$imageFile');
//get timestamp data
$phptime = time();
//modify timestamp to readable format
$mysqltime = date ("Y-m-d H:i:s", $phptime);
//get IP address of user
$thisIP = $_SERVER['REMOTE_ADDR'];
//get additional info from query string
$thisSerial = $_SERVER['QUERY_STRING'];
//prepare file to write
$outfile=fopen($filename, "a");
//create string to write to file
$outstring = "$thisSerial \t $thisIP \t $mysqltime\n";
//write data to file
fwrite ($outfile, $outstring); //writing
//close file for writing
fclose ($outfile); //and we're done
?>
In order to use this code, first copy into a text file and save as tracker.php, or some other name that you'll be able to remember. Then, simply change the first two lines to reflect the names of the picture and the server you will be using. Then, upload tracker.php, as well as the support image to your server, via FTP. Make sure the image you need to serve is in the same folder as the script itself, or remember to add the path correctly to the file name.
Implementation in your email is simple, too. Instead of linking directly to an image, link it to the file that you have uploaded, like this:
<img src="http://www.yourwebsite.com/tracker.php?DATA">
Replace "DATA" with either a customer serial number or the client's email address.
Now, when you want to see who is opening the mail you send, just go to http://www.yoursite.com/openLOG.txt, or whatever name you have given to the output log file.