ASP/AJAX Link Tracker with Microsoft Access .mdb datafile
asp/mdb/ajax Link Tracker
===================================================================
Glenn Jones created an AJAX Link Tracker and wrote about it at:
http://www.glennjones.net/Post/805/AjaxLinkTracker.htm
One of the more interesting aspects of Ajax is the ability to track a user’s
interactionwithin the browser. I wanted to investigate navigation patterns,
so I have written an Ajax based link tracker. If you press the "Ctrl" and "X"
keys you will be presented with an overlay which displays links usage by percentage.
This functionality was created with JavaScript and a very simple API.
===================================================================
Glenn didn't have time to publish the code for the backend API, but did
graciously post detailed descriptions for the methods addClick and getClicks.
From his AJAX Link Tracker article, I was able to write simple backend .asp scripts
to save and read data from an MS Access .mdb file.
I modified Glenn's .js file to also show number of hits per link in parenthesis.
This code is released under the GPL License. There is no guarantee or warranty,
expressed or implied.
There is also a php/MySQL version at: http://ekstreme.com/phplabs/ajax-link-tracker.php
asp-ajax-LinkTracker v1.0 Installation Instructions
===================================================================
Updates may be found at http://www.envador.com/asp-ajax-LinkTracker/
1. Edit linktracker.js
A. Edit Line 67
Line 67 starts with: apiurl = "http://yourserver/LinkTracker/addClick.asp...
Change the apiurl value to the URL of your addClick.asp file
B. Edit Line 119
Line 119 starts with: apiurl = "http://yourserver/LinkTracker/getClick.asp...
Change the apiURL value to the URL of your getClick.asp file
Note: don't get addClick.asp and getClick.asp mixed up in A. and B.!!!
2. Add references to javascript files
Add the following lines anywhere between the tags of your webpages:
Any pages that you have this done will then be LinkTracker-enabled.
<script language="javascript" src="/LinkTracker/prototype_ajax.js" type="text/javascript"></script>
<script language="javascript" src="/LinkTracker/linkTracker.js" type="text/javascript"></script>
Note: be sure to verify that src="" values point to the correct locations of your .js files
3. Add CSS class to your website's CSS file:
.linklabel{
position: absolute;
z-index: 500;
padding-left: 2px;
padding-right: 2px;
color: #FFF;
border: solid 1px #000;
background-color: #B5494A;
font-size: 9px;
}
Note: If you don't use a .css file (you should!) you can alternately add this
anywhere between the tags of your webpages:
<style type="text/css">
.linklabel{
position: absolute;
z-index: 500;
padding-left: 2px;
padding-right: 2px;
color: #FFF;
border: solid 1px #000;
background-color: #B5494A;
font-size: 9px;
}
</style>
4. On your web server, you (or your provider) may need to set permissions on
on the .mdb file to give IUSR_ read/write access
5. There have been reports that ctrl-x doesn't work in FF so for now, use IE to view.
You have to have at least one click to view stats. Otherwise you'll get a javascript error.
===================================================================
Optional
Change default hotkey
You can change the "hotkey" by editing line 87 of linktracker.js You can find a list of
Dec ascii codes at www.lookuptables.com . Just change keyID = 88 to whatever number character
you want. Be sure you don't use a reserved key combination.
Rename the .mdb file
Even though adding link tracker abilities is pretty much giving the entire world access
to viewing your stats. Even changing your hotkey only slightly obscures this. Anyone
familiar with .js could easily figure out your hotkey. That said, it's still a good idea to
not make it too easy to get all of your data. Make it harder for nosey parkers by renaming
the .mdb data file and updating config.asp file line 9 (starts with dbLocation=...)
Updates may be found at http://www.envador.com/asp-ajax-LinkTracker/
|