Google Analytics: Tracking outbound links


/ Published in: jQuery
Save to your folder(s)



Copy this code and paste it in your HTML
  1. $('a:not(.no-tracking)').each(function(){
  2. var link = this;
  3. if (link.hostname && link.hostname !== location.hostname){
  4. $(link).bind('click keypress', function(event){
  5. var code = event.charCode || event.keyCode;
  6. if (!code || (code && code == 13)){
  7. _gaq.push(['_trackEvent', 'Outbound Links', this.href, this.title]);
  8. };
  9. });
  10. };
  11. });

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.