The idea is simple, every time an outgoing link is clicked, we will load an XML file at the backend and pass the URL of the outgoing link or an associated unique ID (e.g., web trends ID in case we are using a web analytics software such as Web Trends).
This will leave a stamp of the outgoing link on the web server logs, which we can then use to get the required statistics, e.g., we can use web trends to analyze existing logs or can build a custom software to analyze the logs, there are also a lot of free tools available to analyze your web server logs.
Here is the code:
<script language="JavaScript" type="text/javascript">
var wtrendsID = "web trends tag will go here";
function Tracker(xmlpath, url)
{
if (window.ActiveXObject)
{
btracker=new ActiveXObject("Microsoft.XMLDOM");
btracker.async=false;
btracker.load(xmlpath);
}
else if (document.implementation && document.implementation.createDocument)
{
btracker= document.implementation.createDocument("", "", null);
btracker.async=false;
btracker.load(xmlpath);
}
else
{
alert(‘Your browser does not allow this script.’);
}
}
function customPopup2(url, features)
{
var xmlpath = "tracker.xml?" + wtrendsID;
Tracker(xmlpath, url);
window.open(url, ", features);
}
//Following can be used to trigger the offsite URL
<A href="javascript:customPopup2(‘http:
You can replace wtrendsID
with the outgoing link and pass it as tracker.xml?outgoing=www.outgoinglink.com and then can parse / filter all the logs with outgoing keyword to get all stats on the outgoing links clicked.
How to track outgoing links using JavaScript and XML is a post from CoolWebDeveloper.com
Related Posts
- ASP self populating drop down list using JavaScript
Related posts brought to you by Yet Another Related Posts plug in.