/ Published in: jQuery
This uses the Event Tracking system rather than a '/outbound'
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<script type="text/javascript"> $(document).ready(function() { $('body a').filter(function() { var theHref = this; if (theHref.hostname && theHref.hostname !== location.hostname) { $(theHref).not(".noAutoLink").attr('target', '_blank').bind('click keypress', function(event) { var code = event.charCode || event.keyCode; if (!code || (code && code == 13)) { var fixedLink = this.href; var _gaq = _gaq || []; fixedLink = fixedLink.replace(/https?:\/\/(.*)/, "$1"); _gaq.push(['_trackEvent', 'Outbound', 'Click', fixedLink]); }; }); }; }); }); </script>