Why? InterNetworking
Web Page Hit Counter

In the web community, everybody and his brother have clamored about wanting a hit counter in their home page. These are generally implemented (poorly) with a cgi-bin program that returns a graphic. It looks ugly and doesn't work for folks who don't load the images or have text-only browsers. The other less common method is using a server-side include executable program which is insecure at best and not very efficient (requires an extra unix process "fork")

We have a better way. We added a server side include "counter" function, built in to the server. Now you can have a page hit counter with none of the traditional problems. In fact, its so efficient that we can afford to offer it to all of our web customers.


How to set it up

First, create a file to hold the value of the counter.

The first thing you have to do is create a file to hold the value of the counter. This is an ASCII text file which contains one line on which the the counter value is stored. This file must always have the extension ".cnt". The file can begin with any name, but we recommend that you use the same base name as the .shtml file you intend to use it in. So, if your web page was named, "index.html," then name the counter file, "index.cnt".

When you put the counter file on the server, it must have special "access permissions." It must be set read/write by user, group, and other so that the HTTP server can read and update it. You can use the chmod command to do this, or if your web administrator has set it up properly, you can use a countifier program which sets it so that only you and the server can write to it.

Next, turn your HTML document into a SHTML document.

The next thing you have to do is adjust the filename extension of your web page so that the server recognizes it as containing server-side includes. Just change the extension to .shtml. So, for instance, if your web page was named "index.html" or "index.htm", your new web page should be named "index.shtml".

Finally, add the counter to your SHTML document.

Add the counter directive in your web page where you want the counter to appear. This directive looks like a HTML comment. In its simplest form, its "<!--#counter file="filename" -->". Filename should be the base name of the counter file, without the ".cnt" extension. So, if your counter file is named "counter.cnt", the counter directive you would use is "<!--#counter file="counter" -->". There you go, you now have a counter in your page. Bring up Netscape and try it out!


Advanced Options:

You can do quite a bit more with the counter than just add one to it for each hit. You can keep track of page hits silently, adjust the appearance of the counter, and even do things like rotating your home page through several backgrounds. Here is the list of options you can give the counter directive:

<!--#counter silent="no" width="0" nocommas="no" min="0" max="2147000000" rollover="no" increment="1" ith="no" gfx="#" file="counter" include="file%i.html" debug="" -->

Where:

Oh yeah. By the way, you are the [Counter: /home/dirtside/www/counter.cnt not found in /home/dirtside/www/count.shtml][Counter: no valid file= in #counter] person to read this page.

Enjoy!


Suggested Uses:

Basic hit counter

Add this to your web document:
Welcome, you are the <strong><!--#counter ith="yes" file="counter" --></strong> person to access this web page.

And create the counter.cnt file. It looks like:
Welcome, you are the 1,234,567th person to access this web page.


Revision History

v1.5.1-1

v1.5a-1


[Go Back][Rates][Why?][EFF]