Tutorial: ASP Based Hit Counter

Web Page Counter

Web Page Counters are used to determine the number of visitors a certain page receives. Each time a visitor looks at a page with a counter, the counter is incremented and the number is displayed to the visitor.

In this guide we will show you how to insert Marshall’s counter into your web page on www.marshall.edu. Please note that this counter will only work for pages that end in .asp and are on the www.marshall.edu server.

Using the Counter
To use Marshall’s counter, you must insert a specific piece of HTML code in your web page. Whenever a visitor requests the page, the server will basically replace this piece of code with your web page’s current visitor count.

To insert the Marshall counter in your web page:

1. Enter the text the will go around the counter.

2. Place the cursor where you want the counter number to appear.

3. Click on the Code tab at the bottom to switch to the Code view.

4. Without moving the cursor, enter the following HTML code exactly as it appears:

<!–#include virtual=”/cgi-bin/counter.asp” –>

5. Click on the Design tab to switch back to the Design view.

Setting the Counter to a Value
It is possible to set the counter to a specific value – such as zero to reset the counter. To do this, you will add a small ASP statement to the page, upload your changes to the server, view the web page, and then remove the statement.

1. Place the cursor some place before the counter.

2. Switch to Code view.

3. Enter the following ASP statement – you may replace the zero with any value to which you wish to set the counter:

<% setCounter = 0 %>

4. Save the web page and upload it to the server.

5. View the web page on the server. This will set the counter. A message stating that the counter has been set will appear where the counter number typically does.

6. Remove the ASP statement you inserted in step 3.

7. Save the web page and upload it to the server.

Congratulations, you have added a counter to your web page. The counter number will not be displayed when you switch back to Design view; however, it will appear once you send the page to the server and view it through a web browser.

This counter script is an easy way to show yourself or your visitors how many visits a particular web page has had. This can be useful in determining how popular a site is and whether or not it is worth the time spent maintaining it.