Skip to content

Instantly share code, notes, and snippets.

@EastSideCode
Created April 7, 2018 15:39
Show Gist options
  • Select an option

  • Save EastSideCode/d5359b2227f193e94dae883abf0c129c to your computer and use it in GitHub Desktop.

Select an option

Save EastSideCode/d5359b2227f193e94dae883abf0c129c to your computer and use it in GitHub Desktop.
Analytics tracking for dynamic elements
jQuery(document).on('click', "a[href^='tel:']", function(event) {
if (typeof gtag !== 'undefined') {
gtag('event', 'Click', {
'event_category': 'Contact',
'event_label': 'Phone',
'event_callback': function() {
console.log("phone tracking sent successfully");
}
});
} // end if variable defined
}); // end click function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment