Page Counters.

We have developed new hit counting software exclusive to TV Science Hosting.

To add hit counters to your pages add the following code snippet to your shtml file(s):

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

Place this in the text where you want the counter digits to appear: It is an HTML comment and should never be seen on your page as viewed in a browser. The counter is reset to zero annually by default. The previous year's value is kept and can also be displayed on your site, see the example below.

With our new counter system, many counters can appear on a page and the values of those counters can be incremented by and/or displayed on other pages. This method can keep your total page impressions in a single counter, for example.

All counters store their old value when they are reset. These values accumulate, up to a maximum of 50 stored counts. These old counts can be accessed to provide historical data.

The new counter program accepts up to six options in the query string:

This is the name (n for name) of the counter you want to use.

There can be one un-named counter per page. This counter is the default if no name is given.

You can have as many named counters per page as you like, provided names for any one page are unique. All names should consist of lowercase letters and numbers; no spaces or punctuation.

You can use a counter from another page by specifying its path, then a question mark, then its name, i.e: /index.htm?fred.

You cannot refer to a page's un-named counter from another page.

This command (c for count) defines the count to be displayed. The incrementing count is cnt_c=0 and is the default.

This command (r for reset) controls the resetting of the counter:

Value for cnt_r.

Reset Action.

yYearly on 1st Jan. This is the default.
mMonthly on the 1st.
wWeekly at Sunday midnight.
dDaily at midnight.
hHourly.
nNever reset.

When the counter is reset the old value is kept and can be shown using: cnt_c=1. This value is never incremented again. Up to 50 old values (0>cnt_c>50) are held in the data file.

True (cnt_p=1) or false (cnt_p=0) value that controls whether the counter value is displayed (p for print).  Default is true. 

True/False (i for increment) value that controls whether the counter increments. Default is false when accessing counters from other pages, true otherwise.

This allows the incrementing count to be displayed in two or more places without double counting.

Old values (cnt_c>0) are never incremented regardless of this value. 

Examples:

HTML:

<p>Visitors this year: <!--#include virtual="/cgi-bin/hitcounter.pl" -->.</p>

Displayed: Visitors this year: .
HTML:

<p>Visitors so far: <!--#include virtual="/cgi-bin/hitcounter.pl?cnt_r=n" -->.</p>

Displayed: Visitors so far: .
HTML:

<p>Visitors in <!--#config timefmt="%Y" --><!--#echo var="DATE_LOCAL" -->:
<!--#include virtual="/cgi-bin/hitcounter.pl" -->,last year:
<!--#include virtual="/cgi-bin/hitcounter.pl?cnt_c=1" -->.</p>

Displayed: Visitors in : , last year: 45.
HTML:

<p>Visitors in <!--#config timefmt="%B" --><!--#echo var="DATE_LOCAL" -->:
<!--#include virtual="/cgi-bin/hitcounter.pl?cnt_r=m" -->, last month:
<!--#include virtual="/cgi-bin/hitcounter.pl?cnt_r=m&cnt_c=1" -->,
and since inception: <!--#include virtual="/cgi-bin/hitcounter.pl?cnt_r=n&cnt_n=fred" -->.</p>

Displayed: Visitors in : , last month: 79, and since inception: .

The counters in these examples are live, pretty much. Try reloading the page to see them change.

<!--#include virtual="/cgi-bin/hitcounter.pl?cnt_p=0&cnt_i=1&cnt_n=/index.htm?global&cnt_r=m" -->

It's home page is /index.htm and its name is global. It is reset on the 1st of each month. Place this code in the footer of all the pages of your website and you have a count of global page impressions. Read values using:

<!--#include virtual="/cgi-bin/hitcounter.pl?cnt_p=1&cnt_i=0&cnt_n=/index.htm?global&cnt_r=m" -->

Cut and paste these examples to create your own counters. Remember to cut the yellow HTML and to paste it as 'plain text' into the 'HTML View' of your editing software. If you have any difficulty then these examples can also be found in a text file.

Notes:

You must give your files an .shtml extension to use counters within the page.

Add counters to as many pages as you like up to about 80 in total. The program will exit with an error if too many counters are set up.

If you rename a page then the counter(s) for that page will all be reset to zero.

Distinguish between counters and counts. Each counter has a current value (cnt_c=0), this is the one that is incremented. Older counts for each counter are kept for subsequent use.

Each page has an un-named counter, which is the default for that page unless you supply a name using cnt_n=name.

How does this process work? When the page is served by Apache Webserver it scans each page for the string: <!--#include
It then replaces the command string (up to -->) with the results of the command, after which the page is delivered to the surfer.

If you wish to know who is visiting your site and where they're going, then install our powerful page logging which provides more detailed information.

This counter system can be built into a full-blown hit statistics package.

For more information on using timefmt see date_fmt from the logging section. The formatting string is identical except that spaces can be used directly.

When a page with a counter is first accessed the string "counter initialised" will be shown. The numeric count will be shown on subsequent occasions.

Some of the examples on this page are currently broken, due to a bug in Apache Webserver, see: https://issues.apache.org/bugzilla/show_bug.cgi?id=39369.


 Go to the TV Science Ltd. Homepage.


Legal Information. Last update of this page: . E-Mail