Created
April 7, 2018 15:53
-
-
Save EastSideCode/7d67b63b5914f7fd8fce491a45519515 to your computer and use it in GitHub Desktop.
Analytics tracking for google maps directions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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