Shoora
4/16/2015 - 8:22 AM

This code, placed in the footer, and with Google Analytics Universal Tracking in place, will turn all links into GA events which can be trac

This code, placed in the footer, and with Google Analytics Universal Tracking in place, will turn all links into GA events which can be tracked in real-time or in the Events tab

<script>
/* Replaces all the links with a Google Analytics tracking link */
$( document ).ready(function() {
  $("a").each(function() {
  var title = $(this).attr('title');
  if(title){
    var googleLink = 'ga(\'send\', \'event\', \'Link\', \''+title+'\');';
    $(this).attr('onClick',googleLink)
  }
  })
});
</script>