Shoora
10/3/2018 - 5:58 PM

How to use jQuery to track Custom Events like Phone Number and Button clicks with Google Universal Analytics.

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
});