Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tracking links clicked on

Status
Not open for further replies.

jdgonzalez

Programmer
May 11, 2004
72
US
Hi everyone,

I'm new to asp and asp.net so I'm hoping someone can help me out. Without having to purchase any additional software, I'd like to track the links that are currently utilized on my site. Is there a way to initiate a database connection using an onsubmit() routine or something similar?

Any options would be greatly appreciated.

Thanks
 
for that all the links will have to go to an asp page, e.g:

<a href="Track.asp?Linkname=Link1">Link1</a>
<a href="Track.asp?Linkname=Link2">Link2</a>

in track.asp read the linkname, save it to database and redirect the user to the correct link...

Known is handfull, Unknown is worldfull
 
Here's what I did...

Wrote code that will insert into a table information that I want to capture (remote IP address, page name, etc)

Here's my code:
Code:
<%
Dim cnTrans, strTransSQL

set cnTrans = server.CreateObject("ADODB.Connection")

cnTrans.ConnectionString = GetConnection()
cnTrans.Open

strTransSQL = "INSERT INTO TransLog (RemoteAddr, Page, Querystring) VALUES ('" & request.ServerVariables("REMOTE_ADDR") & "', '" & request.ServerVariables("URL") & "', '" & request.QueryString() & "');"

if request.querystring("debug") = "SQL" then
	response.write "<br><hr>" & strTransSQL & "<hr><br>"
end if


if left(request.ServerVariables("REMOTE_ADDR"),7) <> "192.168" then
	cnTrans.Execute strTransSQL
end if

cnTrans.Close
set cnTrans = nothing
%>

This is in an include file called "TransLog.asp"
Any page that I want to track:

Code:
<!-- #include virtual="inc/TransLog.asp"-->

There's also the IIS logs that you can play with. There is even an object that will let you interact with the IIS log pretty easily.

Code:
Dim objLogUtil

Set objLogUtil = Server.CreateObject("MSWC.IISLog")

I HIGHLY reccomend "ASP In a Nutshell". (part of the O'Reilly collection) MAJOR help when playing with ASP.

Hope this helps!

gtg.jpg

GTG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top