If you are under Apache, there's an even easier way to do it: use SSI (Server Side Includes). Most servers now require the host page be named with a ".shtml" (the 's' is for 'server parsed') before parsing a page, but it works like gangbusters. You don't even need to use an image, you an emit the count as pure text.
The syntax looks like this:
<!--#include virtual="script_name.ext"-->
Just put that link in your HTML page (with the .shtml extension), and whatever text the script "script_name.ext" spits out will show in the HTML page as if it had always been there.
The script needs to set the MIME type to "text/html", even though it is just going back to the server for inclusion before being sent to the client. In PERL, you'd do that with
print "Content-Type: text/html\n\n";
Then just print your counter (after reading from a file, updating the file, etc.), and you're done.
NOTE: your server (even if Apache) may not be configured for SSI. I'm pretty sure the default is for SSI to be on, but only applied to .shtml extensions. The default used to be to parse all .html (or .htm) files, but that chews up a lot of processor time parsing pages with no includes.