Skip to content

Instantly share code, notes, and snippets.

@Garconis
Created January 8, 2018 17:41
Show Gist options
  • Save Garconis/625eb196cbee4607fe61bf05eba765db to your computer and use it in GitHub Desktop.
Save Garconis/625eb196cbee4607fe61bf05eba765db to your computer and use it in GitHub Desktop.
Add Google Analytics Events via jQuery
// Category > Action > Label
jQuery(document).ready(function() {
//Log GA Event for Sidebar MailChimp form submit click
jQuery('#mk-sidebar #mc-embedded-subscribe').click(function() {
ga('send', 'event', 'Subscribe', 'Click', 'Sidebar');
});
//Log GA Event for Top Bar MailChimp form submit click
jQuery('#mailchimp-top-bar .mctb-button').click(function() {
ga('send', 'event', 'Subscribe', 'Click', 'Header');
});
//Log GA Event for Bloom Popup MailChimp form submit click
jQuery('.et_bloom_popup .et_bloom_submit_subscription').click(function() {
ga('send', 'event', 'Subscribe', 'Click', 'Popup');
});
//Log GA Event for Bloom Posts Bottom MailChimp form submit click
jQuery('.et_bloom_below_post .et_bloom_submit_subscription').click(function() {
ga('send', 'event', 'Subscribe', 'Click', 'Posts Bottom');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment