Help Search Campus Map Directories Webmail Home Alumnae Academics Admission Athletics Student Life Offices & Services Library & Technology News & Events About the College Navigation Bar
MHC Home Using the Document Interface

Adding Counters

Any page on the MHC Web site can have a hit counter attached to it. The counter keeps track of the number of times the page is accessed, throwing out hits by the same person within a half-hour period. This way the counter is not increased every time someone so much as presses the Reload button in their browser.

Counters which use the Document Interface have the following restrictions:

There are two methods for creating counters. The method below applies to documents which use the Document Interface. Other documents must use server-side includes, which are described here.


The .COUNTER Command

Syntax: .COUNTER [Quiet] [Reset] [Since] [Long]

A counter can be added to any page by simply adding one line of code to an existing page which uses the Document Interface. By default, the .COUNTER command produces just the number of hits to the page. You could include it in a HTML file as part of the sentence "X awesome people have surfed this page," like this:

<HTML>
   <HEAD>
      <TITLE>Counter Sample Page</TITLE>
   </HEAD>
   <BODY>
      <!--.banner off-->
      <!--.made "Dan Wilga"-->
      <!--.maintains "Dan Wilga"-->
      <H1>Counter Sample Page</H1>
      <P><!--.counter--> awesome people have surfed this page.
   </BODY>
</HTML>

Click here to see this page in action.


Options

Since

Using this option, you can display the date at which the first hit occurred. Example:

<!--.counter--> awesome people have surfed this page since <!--.counter since-->.

6,724 awesome people have surfed this page since April 22, 1998.

Long

This option produces a "canned" version of the full sentence: "This page has been accessed COUNT time(s) since DATE". Example:

<!--.counter long-->

This page has been accessed 6,724 times since April 22, 1998.

Quiet

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. Example:

You can't tell, but this page <!--.counter quiet-->has a counter.

You can't tell, but this page has a counter.

Reset

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:

<!--.counter reset-->

When successful, the string [COUNTER RESET] is displayed. Be sure to remove this line of code afterward, or your counter will never increase.


Tips

* 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.

* When testing the counter with a browser, you must go the actual Internet address. You cannot view it by using Netscape's File->Open command or by dragging the file's icon to Netscape.

* The same functionality of the .COUNTER command can also be achieved by using the $Count, $CountSince, and $CountLong variables.

----------------------------------------

Home | Directories | Web Email | Calendar | Campus Map | Search | Help

About the College | Admission | Academics | Student Life | Athletics
Offices & Services | Giving | News & Events | Alumnae | Library & Technology

Copyright © 1998 Mount Holyoke College. This page created by Dan Wilga and maintained by Webmaster. Last modified on April 13, 1998.