The Page Counter component creates a PageCounter object that counts and displays the number of times a Web page has been opened. At regular intervals the object updates the number of hits so that in the event of a server shutdown, the data is not lost.
NOTE:Courtesy Microsoft documentation for some of the information used in this section.
Counts and displays the number of times a Web page has been opened. This count is updated at regular intervals. PageCounter object does not get updated until a page hit event occurs. You need to call PageHits method to increment the page counter.
Returns the number of times a specified Web page has been opened.
object.Hits([ WebPagePathInfo As String])
Long. Indicates the number of times the specified Web page has been opened.
If no parameter is specified, the hit count for the current page is displayed.
This example displays the number of times the specified page has been opened.
<% Set MyPageCounter = CreateObject("MSWC.PageCounter") MyPageCounter.PageHit This Web page has been viewed <%= MyPageCount.Hits %> times.<P> Page Myscript.asp has been viewed <%= MyPageCounter.Hits("/VirtualDir1/Myscript.asp") %>
Increments the hit count for the current Web page.
object.PageHits()
None.
Long. Indicates the new hit count value of the current Web page.
The following example increments the number of times the current Web page has been opened.
<% Set MyPageCounter = CreateObject("MSWC.PageCounter") MyPageCounter.PageHits%>This Web page has been viewed <%= MyPageCount.Hits %> times.
Sets the hit count for a specified Web page to 0.
object.Reset( WebPagePathInfo As String)
None.
If no parameter is specified, the hit count of the current page is reset.
This example resets the counters for the current Web page and the page MYPAGE.ASP.
<% Set MyPageCounter = CreateObject("MSWC.PageCounter") MyPageCounter.Reset MyPageCounter.Reset("/VirtualDir1/mypage.asp") %>(The following two values should be 0) <BR> Hits to this page = <%= MyPageCount.Hits %> <BR> Hits to mypage.nsn = <%= MyPageCount.Hits("/VirtualDir1/mypage.asp") <BR>