Monday, February 21, 2011

Count Page Hit in Classic ASP

It is important to know how many hits your Web pages get. This data helps determine how changes to your Web site may affect your customers' viewing habits. More importantly, it provides useful insight as to how customers are navigating through your site and where ads should be placed. Sites with high trafficking have higher advertisement prices associated with them. The data gathered from a page hit counter provides you with trafficking information to begin negotiating advertisement prices for your Web pages.

The Page Counter component uses an internal object to record page hit-count totals for all pages on the server. At regular intervals, this object saves all information to a text file so that no counts are lost due to power loss or system failure. The Page Counter component uses the following three methods:

  • Hits(). This displays the number of hits for a Web page. The default is the current page.
  • PageHit(). This increments the hit count for the current page.
  • Reset(). This resets the hit count for a page to zero. The default is the current page.
 An in-use sample of this script can be seen at the bottom of the Displayad.asp script. To place a page hit counter on a Web page, place the following script where you want the counter displayed on the page:

<% Set pageCount = Server.CreateObject("MSWC.PageCounter") %>
<% pageCount.PageHit %>
You are visitor number <% =pageCount.Hits %> to this Web site.

No comments:

Post a Comment