Adding
a Hit Counter to an MHC Web Page
A hit counter keeps track of the number of times a Web page is
accessed. Hits by the same person within a half-hour period are
discarded; the counter is not increased every time someone presses
their browser Reload button. A hit counter can be added
to any MHC Web page. To conserve system resources, it is best to
only use the counter on the "homepage" of a set of pages.
This actually gives a fairly good impression of how many people
access your site, since it is usually the place where they enter.
Before
adding a counter, please read the overview
of counters.
Counters must be entered in the HTML source view of a file, that
is, among the tags like <HEAD> and <BODY>.
Overview of Counters
To conserve system resources, only use a counter on the "homepage"
of a set of pages. This provides a good impression of how many people
access your site, since it is usually the place where they enter.
Counters have the following restrictions:
- They may only be used in pages which are on www.mtholyoke.edu
or home.mtholyoke.edu.
- They are numeric only. They do not provide a graphical image.
- The name of a page to include a counter must end in
.htm,
.html, .shm or .shtml.
- The hidden counter only works on pages that end in
.shtml.
A counter can be added to any page by adding one line of code
to an existing HTML page.
Hidden Hit
Counter
A hidden hit counter counter is invisible to visitors.
The file extension has to be .shtml for this counter
to work. Note: if the page already has a counter code, be sure to
remove the old counter. To view the counter, after inserting source
code (see below), add "?counter" to the end of the URL;
i.e.: www.mtholyoke.edu/help/creatingpages/style/restricted/policy/?counter
Please do not publish any version of this URL on any Web pages.
| Source code for Hidden Counter;
the code works equally well in <HEAD> or <BODY>:
<!--.if
"$&re_match('$%REQUEST_URI','\\?counter\$')"
ne '';
clearpage;
echo '<html><head></head><b'.'ody><p
align=center><b>Hit counter:</b> ';
counter long;
echo '</p></body></html>';
exit;
else;
counter quiet;
endif--> |
Hit Counter as Part of a Sentence
X people have visited this page.
You can include a hit counter as part of the sentence, in an HTML
file. View sample.
Copy this source code and then paste
into HTML:
<!--#include
virtual="/cgi/count.pl"--> people have visited
this page. |
Long Sentence with Counter
and Date of First Hit
X people have visited this page since __ (date).
This counter includes the number of hits in a sentence and is followed
by the date (since). Using this option, you can display the date
at which the first hit occurred. View sample.
| Copy this source code and then
past into HTML:
<!--#include
virtual="/cgi/count.pl"-->
people have visited this page since
<!--#include virtual="/cgi/count.pl?since"-->. |
Quiet Counter
You can't tell, but this page has a counter.
When this option is used, the page count increases but no number
is displayed. This is useful when you want to count a page's hits
without the reader knowing. You can find out how many hits there
have been at a later date by temporarily removing the "quiet"
option from the file.
| Copy this source code and
then past into HTML:
<!--#include
virtual="/cgi/count.pl?quiet"-->has a counter. |
How to Reset the Hit Counter
To reset the counter to 1 and the "since" date to the current date,
the reset option can be used.
| You should temporarily add
the following line of code to your page and then view it using
your Web browser:
<!--#include
virtual="/cgi/count.pl?reset"--> |
When successful, the string [COUNTER RESET] is displayed.
Be sure to remove this line of code afterward, or your counter will
never increase.
How to Test a Counter
To test the counter, you must go the actual Internet address on
a Web browser. You cannot view it by using Netscape's File->Open
command or by dragging the file's icon to Netscape.
|