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 %>
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>
This site is visited: [5] times.
And guests visited: [25] pages.
Warning: You must have appropriate permissions on the server to use this counter.
















