Location: > Support > Hit Counter    Site Map

Hit Counter

counter.pl is a simple text-based hit counter. It supports multiple hit counts for separate pages, logging (time, IP, page, etc), and the ability to view hit counts without modifying them.

Counters are stored in your web root directory in the file _counts.txt. Log info is stored in the same location in the file _counts_logs.txt. These are plain text files which can be viewed with your favorite text editor. NOTE: if you modify _counts.txt, make sure the file has unix line endings (\n)!

Using counter.pl

Use counter.pl by placing the following SSI call in one of your web pages:

<!--#include virtual="/cgi-bin/counter.pl"-->

Options

Now that the basic function of counter.pl is working, you can explore the other features. Parameters are passed in the form of 'name=value'. Multiple parameters are connected with '&' (an ampersand). Parameters are appended to the counter.pl filename in the SSI call in your web page (as shown above), after a '?' (question mark). An example should make that much more clear:

<!--#include virtual="/cgi-bin/counter.pl?id=page1&log=1"-->

id -- Multiple pages: There are many cases where you may want separate pages to have separate hit counts (so you can keep track of traffic to each page independently). Pass the parameter 'id=PAGENAME', and make 'PAGENAME' a short alphanumeric (no spaces or punctuation!) identifier for the page, and calls to counter.pl will increment only the hit count for that page. Additionally, you could use the same counter on different pages.

view -- don't increment hit count: If you give this parameter a true value (i.e., 'view=1'), the hit count will NOT be incremented. Rather, the current hit count will simply be displayed. This is useful for "overview" pages that you may create to keep track of the hits on your other pages.

log -- turn on logging. You may pass 'log=1' to turn on logging. This means that each hit will be recorded in the log file '_counts_logs.txt'. Logs are kept in the following form:

[TIME] ID - COUNT - MODE - IP

TIME is the time of the hit.
ID is the page ID (as specified with 'id'). 'default' is used for pages with no specified page ID.
COUNT is the hit count that was displayed.
MODE is either 'INCR' (increment) or 'VIEW'. This specifies whether the hit count was incremented (which is the default) or simply viewed (if 'view=1' was given, as explained above).
IP is the IP address of the computer that accessed the page.

You can combine the above options like so:

<!--#include virtual="/cgi-bin/counter.pl?id=main&view=1&log=1"-->
or
<!--#include virtual="/cgi-bin/counter.pl?id=main&log=1"-->
or
<!--#include virtual="/cgi-bin/counter.pl?id=main&view=1"-->
or... well, you get the idea.

Order does not matter when specifying these options.