A simple to use ASP home made HIT COUNTER it measures unique visitors and page views of your site, it’s very simple to setup and use. So lets get to business:
1 Setup
It’s very easy to setup there are two ways to do it.
The first way is to copy and paste the script below in the top of every asp page.
The second way is to copy the script below and save it in a file for example counter.inc then in the top of your asp pages paste this <!–#include virtual=”$path/counter.inc”–>
$path stands for the path where you saved your file.
<% Dim Path Path = Server.MapPath("/counter.txt") Dim PageViews, UniqueVisitors Dim FSO, FO Set FSO = Server.CreateObject("Scripting.FileSystemObject") If ( FSO.FileExists( Path ) ) Then Set FO = FSO.OpenTextFile(Path, 1, False) PageViews = cInt(FO.readLine) UniqueVisitors = cInt(FO.readLine) FO.close If ( Session("Returning") <> True ) Then UniqueVisitors = UniqueVisitors + 1 Session("Returning") = True End if PageViews = PageViews + 1 Set FO = FSO.OpenTextFile(Path , 2, False) FO.WriteLine(PageViews) FO.WriteLine(UniqueVisitors) FO.Close Set FO = Nothing Else Dim NewFile Set NewFile = FSO.CreateTextFile(Path, True) NewFile.WriteLine("1") NewFile.WriteLine("1") NewFile.Close Set NewFile = Nothing PageViews = 1 UniqueVisitors = 1 Session("Returning") = True End if Set FSO = Nothing %>
2 Use
Now all we need to do is show the results on the pages, and we are going to do that with the next code:
<strong> This site is visited: [<%= UniqueVisitors %>] times. <br /> And guests visited: [<%= PageViews %>] pages. </strong>
And the result looks like this:
This site is visited: [5] times.
And guests visited: [25] pages.
Warning: You must have appropriate permissions on the server to use this counter.
















