Created
January 11, 2014 14:24
-
-
Save bavington/8371498 to your computer and use it in GitHub Desktop.
How to use jQuery to track Custom Events like Phone Number and Button clicks with Google Universal Analytics.
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
jQuery(document).ready(function ($) { | |
$('#quote').on('click', function() { // Tracks clicks for the <a> tag with id="quote" | |
ga('send', 'event', 'button', 'click', 'Quick Form Lightbox Impressions'); | |
}); | |
$('#phonenumber').on('click', function() { // Tracks clicks for the <a> tag with id="phonenumber" | |
ga('send', 'event', 'link', 'click', 'Header Phone Clicks/Touches'); | |
}); | |
$('#contactphone').on('click', function() { // Tracks clicks for the <a> tag with id="contactphone" | |
ga('send', 'event', 'link', 'click', 'Contact Page Phone Clicks/Touches'); | |
}); | |
// View https://developers.google.com/analytics/devguides/collection/analyticsjs/events for information on the function | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment