nathan schmoll's
aspdiscovery

back to main page

e-mail me








Tracking Page Visits Made Easy! -- Part II
<< Go to back to part one

Welcome to the second part in a two-part series on how to track page visits on your web site. This article will discuss how to make a script that allows you to view the URL's that have been passed through track.asp (we made this in part one) and how many times that URL has been passed through.

Below is the code for "trackstats.asp", which will show the stats for track.asp. Before executing this script you must create the database discussed in part one and name it "track.mdb".

<html>
<head>
<title>
Link Tracking System
</title>
</head>
<body bgcolor="#ffffff">
<table border="0" cellpadding="1" cellspacing="0" width="580">
<tr>
<td align="center" colspan="2">
<div align="center">
<center>
<font face="Arial,Helvetica" size="5">
<b>Link Tracking System</b>
</font>
</center>
</div>
</td>
</tr>
<tr>
<td colspan="2"><br></td>
</tr>
<tr bgcolor="#000000">
<td bgcolor="#000000" width="80%">
<font face="Arial,Helvetica" size="2" color="#ffffff">
<b>URL</b>
</font>
</td>
<td bgcolor="#000000" width="20%">
<font face="Arial,Helvetica" size="2" color="#ffffff">
<b>Counts</b>
</font>
</td>
</tr>
<%
c="1"
set myconn=server.createobject("ADODB.Connection")
myconn.open "Driver={Microsoft Access Driver (*.mdb)}; DBQ="&server.mappath("track.mdb")&";"
sql_query="SELECT * FROM trackdb"
set rs=myconn.execute(sql_query)
WHILE NOT RS.EOF
recordpulled="1"
if c="1" then
c="2"
elseif c="2" then
c="1"
end if
dburl=rs("url")
dbcount=rs("count")
%>
<tr<%if c="1" then%> bgcolor="#ebebeb"<%end if%>>
<td<%if c="1" then%> bgcolor="#ebebeb"<%end if%>>
<font face="Arial,Helvetica" size="1">
<b><%=dburl%></b></font></td>
<td<%if c="1" then%> bgcolor="#ebebeb"<%end if%>>
<font face="Arial,Helvetica" size="1">
<b><%=dbcount%></b></font></td></tr>
<%
rs.movenext
wend
%>
</table>
</body>
</html>


copyright © 2001, nathan schmoll. all rights reserved. questions? comments? suggestions? e-mail me!