Web Page Hit Counter


Web Page Hit Counter



If you had a web page hit counter with another provider, it was probably a .gif image loaded seperately from the page. These are generally implemented with a cgi-bin program that returns a graphic. It graphic is ugly and looks out of place on your page. Worse, it doesn't work for folks who don't load the images or have text-only browsers and it ties up expensive processing resources on the server.

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, turn your HTML document into a SHTML document.

The first 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".

Next, 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.shtml," then name the counter file, "index.cnt". Put this file on the server, with one line containing the number you want the counter to start at.

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 from your FTP program or from the Unix shell prompt.

On the @NAME@ web server, you should use the countifier program instead. This will convert all .cnt files in your directory into counter files.

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. Open your web browser 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="" -->


Oh yeah. By the way, you are the person to read this page.


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