Tracking visitors to pages

E

Emmett Power

Hi,

I am inviting customers to view a page on my website. The invitation
email includes the url and sufficient variables to identify them
(email, name, company)

I want to track who actually views the page and capture the data in a
database. Obviously I could ask them to submit a form but I'd rather
not do that.

How can I do this? Should I, for example, have a hidden form which
automatically submits through JavaScript or is there some other, more
elegant, solution?

Any suggestions would be appreciated.

Regards


Emmett Power
 
G

Gary Jones

Emmett Power eh ? I've not heard that name for a while...

What the previous respondant said is quite correct, plus you can also
capture stuff such as their IP address and Browser type from the
Request.Servervariables collection

e.g. (making certain assumptions about database type, structure & location)

<%
Option Explicit
On Error Resume Next
Dim strName, strCompany, strEmail, strBrowserDetails, strIPAddress
Dim objdbConnection, objdbRecordset
Dim strConnectionString, strSQL
Dim strDateTime, strMessage, intDebug
intDebug = 0 'Change to 1 if you want to see any trace messages

With Request
strName = .QueryString("Name")
strCompany = .QueryString("Company")
strEmail = .QueryString("Email")
strBrowserDetails=.ServerVariables("HTTP_USER_AGENT")
strIPAddress = .ServerVariables("REMOTE_ADDR")
strDatetime = Now()
End With

strConnectionString = "driver={Microsoft Access Driver (*.mdb)};" _
& "Driverid=25, FIL=MS Access;" _
& "ImplicitCommitSync=Yes;MaxBufferSize=512;MaxScanRows=8;" _
& "PageTimeout=5;SafeTransactions=0;Threads=3;UserCommitSync=Yes;" _
& "dbq=" & Server.MapPath("./UserData.mdb") & ";"

strSQL = "INSERT INTO UserVisits(VisitDate, Name, Company,Email,
BrowserDetails, IPAddress)" _
& " VALUES ('#" & Left(strDatetime,10) & "#','" _
& strName & "','" _
& strCompany & "','" _
& strEmail & "','" _
& strBrowserDetails & "','" _
& strIPAddress & "')"

If intDebug = 1 Then Response.write("<br>strSQL=" & strSQL)

Set objdbConnection = Server.CreateObject("ADODB.Connection")
objdbConnection.Open strConnectionString

Set objdbRecordSet = objdbCOnnection.Execute(strSQL)
If Err Then
strMessage = "<br><b>An error occurred. Details are as follows</b><br>" &
Err.Description
Else
strMessage = "<br><b>Your details have been logged to assist us in
providing you with blah blah blah...</b>"
End If

objdbRecordSet.Close
Set objdbRecordSet = Nothing
Set objdbConnection = Nothing
%>
<HTML><BODY>
<p>Normal Page Content<p><b><%=strMessage%></b>
</BODY></HTML>
 
E

Emmett Power

Gary,

Thanks for the code. Is that 'the' Gary Jones?

If so drop me a line at Silico Research and let me know what you're up
to.

Regards

Emmett
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top