I\'ve been using a script to track outbound links for a couple of months now. The script WORKS, but in the report generated by Google Analytics many UR
The problem with window.open is that the referrer will be lost. A better solution is to use onmousedown instead of onclick. Having done some tests, I know this work better that using window.open or using setTimeout. You got some false positive from people clicking the right mouse button and not choosing "Open in new tab" or "Open in new window", but onclick doesn't always fire for middle and right click on all browser. It's a choice between the lesser of two evils here.
jQuery(function($){
$('a:not([href*="' + document.domain + '"])').mousedown(function(event){
// Just in case, be safe and don't do anything
if (typeof _gat == 'undefined') {
return;
}
var link = $(this);
var href = link.attr('href');
var noProtocol = href.replace(/http[s]?:\/\//, '');
// Track the event
_gat._getTrackerByName()._trackEvent('Outbound Links', noProtocol);
});
});