Page counters are implemented as image (IMG) tags whose source (SRC) URL is a common gateway interface (CGI) program. Here's an example of an image tag (these will vary from server to server). As you can see, it's just an image with a complicated source URL.
<IMG SRC="/cgi/nph-count?width=6&link=/clients/ross/index.html">
The server keeps a small database of counters. Each counter has a name (such as /clients/ross/index.html) and a non-negative integer value. When the client browser requests the image, the server runs the CGI program which looks up the specified counter in its database (in this case the counter specified in the URL is /clients/ross/index.html), increments the counter, and then constructs and returns an image containing the decimal digits of the new counter value. The server does this last step by decomposing the counter into base ten, and then looking up each digit in an array of ten small digit images 0..9. Thus, each time the page is accessed, each counter in the page is incremented and presented as an image on the page.
Although the architecture of page counting is simple, its
implementation is not portable, and each different kind of server
and service provider may provide variations in implementation.
Some of the more comprehensive webserver statistics gathering systems
diverge from the above as well.