Basically, you write a script in your preferred language, and map that script to yourtrackingscript.gif. ..jpg, png even.
Have done this in asp.net using a http handler.
The script reads the querystring like any other dynamic page (aspnet, asp, php, anything really), then writes it to a db or log file, or does whatever else you want to do with it.
Then set the content-type header appropriately e.g "image/gif", and send back a 1 pixel image, or any other sized image you like.
For just a 1 pixel image, I have opened up a 1 pixel spacer.gif type image in a hex editor, and hard coded it as a byte array to send out as the response, will save a little IO overhead if it gets hit a lot, alernatively, you can read a file from disk or DB and send that back instead.
This is a commonly used trick in email newsletters to track open rates etc.
Often the hardest bit about it is when you don't have enough rights to map the url to the script on a shared machine, but you can develop it as a normal script/program, then get the mapping sorted out once you have it working.
Most modern browsers will respond to a an aspx or php (.etc...) url as an image if it sends the right headers, it's older browsers, browser nanny plugins, and email clients that are the most pernickety about it.