I believe is function is called WebBugs. Yahoo and numerous other sites use this method so they may track a user on an affiliate's site.
Ok, here is one way of doing this.
First the image tag will be as follows:
<img src="http://www.domain.com/image.php">
Create a PHP page on your server called "image.php" and have the image "1by1.gif" you would like to pass thru to the browser within the same directory as "image.php"
<?php
//Do all of your calculations or data mining here
header('Content-type: image/gif');
readfile('1by1.gif');
?>
Thats it!
NOTE: Trying to setcookie might fail on certain browsers(Konqueror and Apple's Safari) Since it has an option to deny Cookies from outside the current page's domain. While this works for most sites, I found it causes problems on sites like Dell.