The Hit Counter plug-in allows you to easily create web documents that include a graphical odometer style hit counter.

Adding Counters to Your Document

The Hit Counter plug-in tracks 'hits' by tracking keywords in the path argument of a request. Keyword hits are incremented every time the plug-in is asked to provide a GIF based on that keyword. (Keywords have nothing to do with the file name they reside in.)

To add a graphical hit-counter to your HTML document, use the IMG tag thusly:

<IMG SRC=".count$foo">

This will insert an odometer-style graphical counter with a default font and a default width of 8 numbers. Note that the choice of keyword is not important - 'foo' is just as valid as 'index.html'. Hits are persistent; that is, they are saved at application shutdown and restored when the application is next launched.

Multiple keywords may be used additively in your request. For example:

<IMG SRC=".count$error.html/bad_url.html">

This tag will include a GIF in your document that displays the sum of the number of times the keywords 'error.html' and 'bad_url.html' have been hit, and increment the hit counts for the keywords 'error.html' and 'bad_url.html'.

Customizing Your Counters

You may choose a custom width for your counter GIF by employing the 'width' keyword:

<IMG SRC=".count$foo/width=6">

This tag will provide a GIF that is 6 digits wide instead of the default 8. The legal range is 1 to 12 digits inclusive.

You may also specify a custom color instead of the default white, by employing the 'color' keyword:

<IMG SRC=".count$foo/color=185">

Any pixels in the counter GIF that are white will be replaced with your color. Colors are indexed against the default 8-bit system color table for the server's system. The legal range is 0 to 255 inclusive. Unless you have some programming savvy, there really is no way to compute a custom color easily - trial and error is the best method. 185 happens to be a nice bright green on my system.

Additionally, you may specify a custom typeface with the 'font' keyword:

<IMG SRC=".count$foo/font=Palatino">

Fonts are stored in resource files in the 'Plug-ins:Counter Files:Fonts' directory in the Quid Pro Quo folder. You may create new fonts by creating new resource files and placing them in this folder. Using your favorite resource editor (ResEdit will do nicely), you will need to create an 'icl8' resource for each numeral, starting with resource ID 6000 for '0', 6001 for '1', etc. At launch Hit Counter will examine your '0' digit and determine its size, up to 32 pixels high/wide, and use those dimensions to stitch all icons together into a GIF. Any icons larger than '0' will be clipped.

Preventing Hijacking

Hit Counter incorporates a feature that allows only documents local to your server to use your hit-counter. This prevents documents at other sites from using your counter and thus dragging down your site's performance. If you wish to allow outside users access to your counter, place a folder called "ok2count" inside the "Counter Files" directory.

Hit Counter uses the gd GIF library, Copyright 1994, 1995, Quest Protein Database Center, Cold Spring Harbor Labs.


Send questions and comments to me, Chris Hawk

Welcome | Contents | Glossary