/ Published in: jQuery
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"); fixedLink = '/outgoing/' + fixedLink; _gaq.push(['_trackPageview', fixedLink]); }; }); }; }); }); </script>