var host = window.location.host; if (window.Prototype) { Event.observe(document, 'mouseup', function (e) { if (window.pageTracker == null) return; var link = Event.findElement(e, 'a'); // Log all left and middle clicks on HTTP/HTTPS links. The logged URL is always relative to the root. if (link && link.href && startsWith(link.href, 'http') && (Event.isLeftClick(e) || Event.isMiddleClick(e))) { var url = link.href.replace(new RegExp('^https?://'), ''); // Strip protocol if (startsWith(url, host)) { // Internal link - strip the hostname and add the link name, if any url = url.substr(host.length); url = addNameAttribute(url, link); } else { url = '/outgoing/' + url; // External link } pageTracker._trackPageview(url); e.stop(); } }); } var addNameAttribute = function(url, link) { if (link.name && link.name != '') return url + (url.indexOf('?') == -1 ? '?' : '&') + 'trigger=' + link.name; else return url; } var startsWith = function(string, substring) { if (string.length == 0 || string.length < substring.length) return false; return (string.substr(0, substring.length) == substring); }