tmartin314 tmartin314 - 5 months ago 22
HTML Question

Track impressions from image src tag

I need to include an image tag that references a script:

<img src="http://the.site./script.php"/>


But I'm not sure of how to make this invisible. Sort of behind the scenes to track impressions.

2 Questions:


  1. How do I properly layout the tag?

  2. What would script.php contain?


Answer

You could make it into a web bug - the script could return a 1x1 transparent GIF image (create a 1x1 transparent GIF and save it on your server):

<?php
header('Content-Type: image/gif');
// whatever tracking/data mining you want to do with the data, do that here.
readfile('your_1x1_file.gif');
exit;
?>

Note that this is the technical side of things, the legal part on web tracking etc. is up to you (and your company's legal dept.)

Comments