Skip to content

Instantly share code, notes, and snippets.

@sparkalow
Last active September 27, 2019 04:17
Show Gist options
  • Save sparkalow/4d2ef853bb93862f9a46 to your computer and use it in GitHub Desktop.
Save sparkalow/4d2ef853bb93862f9a46 to your computer and use it in GitHub Desktop.
jQuery Google Analytics Events
$('[data-ga-event]').on('click',function (event ) {
var $el = $(this);
var category = $el.data('ga-event'),
action =$el.data('ga-action'),
label = $el.data('ga-label');
ga('send', 'event', category, action, label);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment