Skip to content

Instantly share code, notes, and snippets.

@bavington
Created January 11, 2014 14:24
Show Gist options
  • Save bavington/8371498 to your computer and use it in GitHub Desktop.
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.
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