History of web counters and web analytics
Web counters started out as a fad on the internet around 1995-1996. The first web counters were perl scripts or C programs that were included in web pages using "server-side includes" in .shtml files (for "server-parsed html"). This technology has been almost entirely supplanted by the likes of PHP.
Then, someone had the idea of offering a hosted counter service. You would include an image tag on your page. The counter server would increment its count for your site and piece together an image that usually resembled an odometer.
In 1996, a site opened up called the Web-Counter, at counter.digits.com. It was a classic case of viral marketing. People would sign up, put the counter on their pages, which others would see, who would then sign up for their own. Digits.com was quickly overwhelmed with demand, and soon copycats began offering similar services.
The counter.digits.com counter required you put an HTML code on your page that looked like this:
<IMG SRC="http://counter.digits.com/wc/-d/4/counterguide" ALIGN="middle" WIDTH="75" HEIGHT="20" BORDER="0" HSPACE="4" VSPACE="2">
The odometer-style image looks like:

Offering
free web counters required a lot of bandwidth and was not terribly profitable. New services popped up and quickly disappeared very often.
Some had another idea: rather than simply showing a hit count on an image, why don't we use the same technique to compile hit count statistics over time and show them on a separate page? These services also gathered more information from the headers that browsers would send along with requests for the image such as the User-agent of the browser from which, with a little dark magic, one could deduce the proportions of the brands of browsers people were using.
These new services which sometimes called themselves "trackers" began to compete with each other with the kinds and details of statistics they could gather. Some sent a cookie with the image to try to determine if a hit came from a unique visitor.
Then, someone had another great idea: what if we use javascript to write the HTML for the image tag? That way, one could add extra information about the user into the query string for the image. This was the only way to get information such as screen size or the referer string (which tells the url from which the user found a particular tracked page; see
about tracking referers).
One of the earliest and the best of these variants was Extreme Tracking. Their HTML code looked a lot more complicated:
<font size=1 color=white>
<a target="_top" href="http://t.extreme-dm.com/?login=cguide2">
<img src="http://t1.extreme-dm.com/i.gif" height="38" border="0" width="41" alt=""></a><script language="javascript1.2"><!--
EXs=screen;EXw=EXs.width;navigator.appName!="Netscape"?
EXb=EXs.colorDepth:EXb=EXs.pixelDepth;//-->
</script><script language="javascript"><!--
EXd=document;EXw?"":EXw="na";EXb?"":EXb="na";
EXd.write("<img src=\"http://t0.extreme-dm.com",
"/c.g?tag=cguide2&j=y&srw="+EXw+"&srb="+EXb+"&",
"l="+escape(EXd.referrer)+"\" height=1 width=1>");//-->
</script><noscript><img height=1 width=1 alt=""
src="http://t0.extreme-dm.com/c.g?tag=cguide2&j=n"></noscript>
</font>
Exteme tracking showed a simple logo icon rather than an odometer-style counter.
(Notice also that the extreme tracking code uses a <noscript> tag so that it will still record something for users that have javascript disabled. Of course even this will not work for users that have images disabled.)
Another development was to use the exact same javascript technique to with not an icon but a 1x1 pixel transparent gif. Although rare for free services, this would make it possible to track every page on a site without bothering the user or placing any requirements on site layout.
The next development was to drop the image and just use pure javascript. This was the idea behind Urchin (now called Google Analytics).
The HTML code for Google Analytics, which was to be included on every page you would want to track, looked like this:
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
Very simple! To see what the javascript code actually does,
click here to see it. I'm not promising it's going to be terribly readable.
Urchin used cookie-based sessions to track paths that users took through your site. The advantage to this method over a server-side solution is that it is very, very easy to set up. Disadvantages? It probably slows down page rendering for users, and it will completely ignore users without javascript.
There are now a number of Urchin copycats out there, and like the original web counters that preceded them, they are quickly overloaded as they crop up. Many free ones are currently closed to registration, including Google Analytics.
So that's the history of hosted web counters and web analytics. Some (not all) of the weaknesses of hosted services are avoided by using a
web log analyzer.