Posted By

JonasDoebertin on 02/09/11


Tagged


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

rajashri78
AllKnightAccess
jondiscipulo


Google Analytics: Tracking outbound links


 / Published in: jQuery
 

  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  

You need to login to post a comment.