{ i love code }

HTML:

<a href="size-chart.pdf" data-track="Size Chart">Size Chart</a>

JavaScript:

$(document).ready(function () {
  $('a[data-track]').on('click', function (e) {
    var label = $(this).attr('data-track');
    //_gaq.push(['_trackEvent', 'Links', 'Click', label]);
    ga('send', 'event', 'Links', 'Click', label);
  });
});

Update Aug 5, 2014: New Google Analytics API.

-R

blog comments powered by Disqus

Ramon Torres - iOS developer/product designer

My name is Ramon Torres. I'm a software developer and product designer, currently working at Inkboard building cool stuff.