Skip to content

Instantly share code, notes, and snippets.

@necenzurat
Forked from postpostmodern/track_event.js
Created June 10, 2013 21:44
Show Gist options
  • Save necenzurat/5752654 to your computer and use it in GitHub Desktop.
Save necenzurat/5752654 to your computer and use it in GitHub Desktop.
$('body').on('click', 'a, img, button', function(e) {
var $el = $(e.target);
if($el.data('event-count')) {
$el.data('event-count', ($el.data('event-count') + 1));
} else {
$el.data('event-count', 1);
}
var category = e.target.nodeName;
var action = e.type;
var label = $el.data('event-label');
var value = $el.data('event-count');
ga('send', 'event', category, action, label, value);
return true;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment