jQuery code to track clicks on outgoing links (google analystics)
- by Tristan
Hello, I found this on the web:
$('a[href^=http]:not("[href*=://' + document.domain + ']")').click(function() {
pageTracker._trackPageview('/outgoing/' + $(this).attr('href'));
});
But it's not working. In my Google Analytics account there are no /outgoing/ links showing (it's been 24+ hours since I implemented it).
What's wrong with this code? I'm using jQuery of course ;)
(PS : i already have : <script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA MY CODE");
pageTracker._trackPageview();
} catch(err) {}</script>)