Skip to content

Instantly share code, notes, and snippets.

@EastSideCode
Created April 7, 2018 15:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EastSideCode/7d67b63b5914f7fd8fce491a45519515 to your computer and use it in GitHub Desktop.
Save EastSideCode/7d67b63b5914f7fd8fce491a45519515 to your computer and use it in GitHub Desktop.
Analytics tracking for google maps directions
// track directions
jQuery('body').on("click", "a[href*='maps.google.com']", function(event) {
if (typeof gtag !== 'undefined') {
gtag('event', 'Click', {
'event_category': 'Contact',
'event_label': 'Directions',
'event_callback': function() {
console.log("directions 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