CodeAve.com CodeAve.com - ASP - Read/Write
ASP
·Read/Write
·Script Writers
·Database Display
·Response Objects
·Server Variables
·Random Events
·Articles
·Miscellaneous
·Contents
·What's New?
JavaScript
CSS
HTML
Maps
Links
Mail List
Search
Sitemap


 


Count Click Throughs (With a Db)
Need to track where your users are clicking to from your site? Easily count and display the number of click through from your site with a database. Simply set all the links that you want to track to a single asp document and pass the URL as a querystring variable. The following example will display a page with a few links. Once a link is clicked on it will insert the URL and users IP address into an Access Db and redirect the browser to the URL clicked on. Included in the download is a document that will allow you to view people are clicking to in a number of ways.
View the Output
Text View
Print View
Mail this Link
Download the Code

<% 
' Value for the url being requested
url=trim(request.querystring("url"))

' if no url is detected then show then
' show a page with links 
if url="" then %>

<html>
<title>CodeAve.com(Count Clicks to a Db)</title>
<body bgcolor="#FFFFFF">

<a href="clicks.asp?url=http://www.yahoo.com">Yahoo</a>
<br>
<a href="clicks.asp?url=http://www.aol.com">AOL</a>
<br>
<a href="clicks.asp?url=http://www.excite.com">Excite</a>
<br>
<a href="clicks.asp?url=http://www.mail2web.com">Mail2Web</a>
<br>
<a href="clicks.asp?url=http://www.aspin.com">ASPIn</a>
<br>
<a href="clicks.asp?url=http://www.sas.com">SAS</a>

</body>
</html>
<% 
' if there is a url value detected add it to the db
' and redirect the browser to the url
else 
%>

<%

' Varible for the PC IP address
ip=request.servervariables("remote_addr")

' name of the db that will track the clicks
accessdb="clicks.mdb" 

' Build a connection to the db
cn="DRIVER={Microsoft Access Driver (*.mdb)};"
cn=cn & "DBQ=" & server.mappath(accessdb)

' Create a server record set object
set rs = server.createobject("ADODB.Recordset")

' SQL statement that will insert the url and the ip address
sql = "insert into clicks (url,ip) values('"& url &"','"& ip &"')" 

' insert the values into the db
rs.open sql, cn

' kill the recordset 
set rs=nothing

' redirect to the url 
response.redirect url 
%>



<% end if ' end check for a url value %>

 

 

 



ASP: What's New? | Articles | Script Writers | Database Display | Read/Write
Server Variables | Response Objects | Random Events | Miscellaneous
HTML: Forms | Hyperlinks | Headers | Tables | Hyperlinks | Headers | Text Display
JavaScript: Document Info | Forms | Images | Navigation | Script Writers
CSS: Basics | Page Display | Text Display | Script Writers | Miscellaneous
  • 2014 michael kors
  • air max women 2013
  • 2014 michael kors
  • air max 2014
  • oakley glasses
  • oakley glasses

  • Maps: Map Script Writers | Bing Maps | Google Maps
  • bottes fr
  • ugg boot
  • Privacy Statement

    CodeAve.com is hosted by MyHosting.com
    Donate Food Online with a Mouse Click at TheHungerSite.com
    Donate Land Online with a Mouse Click at TheRainForestSite.com
    © 1999 - 2017 CodeAve.com
    All Rights Reserved

  • Kids jordan 6 rings
  • Jordan retro 10
  • Jordan retro 3