I have a function that binds a function to all third party links within a website. It is working fine, however if someone clicks a link (which is tracked) then presses the back button in their browser and clicks another link that should be tracked, it is not tracked.
I this a known issue with document.ready?
Code:
$(document).ready(function(){
// sets an onclick event to call the tracking scrip
$('a:external').bind('click',function(){ writeTracking(this.href)}, false)
//debug, shows external links
$('a:external').css('background-color',"yellow");
} // end function
); // end ready
Since using the back button doesn't really reload the page, and the bind's were already put into place, this one stumps me. I also have an AJAX call that could be the culprit. I just watched a tutorial on AJAX last week so I wouldn't even know where to begin if this was wrong.
Code:
function writeTracking(linkHref){
var url = "writeFile.cfm?writeUrl=" + linkHref;
if (window.XMLHttpRequest) {
xhr = new XMLHttpRequest();
}
else {
if (window.ActiveXObject) {
try {
xhr = new ActiveXObject("MSXML2.XMLHTTP.3.0");
}
catch (e) { }
}
}
if (xhr) {
xhr.open("GET", url, true);
xhr.send(null);
}
else {
alert("Error");
}
return false;
}
|