jQuery code to track clicks on outgoing links (google analystics)
Posted
by Tristan
on Stack Overflow
See other posts from Stack Overflow
or by Tristan
Published on 2010-04-27T07:23:21Z
Indexed on
2010/04/27
7:43 UTC
Read the original article
Hit count: 226
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>
)
© Stack Overflow or respective owner