Add Google Analytics event tracking to Theme X Pro button

Hi,

I’m trying to add this event tracking code to one of my buttons in theme x pro. See code below.

Where should I add this code for it to work?

onClick="ga('send', 'event', { eventCategory: 'download', eventAction: 'click', eventLabel: 'boek-1-demo'});"

Hey there,

Thanks for writing in! Try this, give your button a class e.g ga_event and then add the following code in the Pro > Theme Options > JS:

jQuery(document).ready(function($){
	$('.ga_event').on('click', function(){
		ga('send', 'event', { eventCategory: 'download', eventAction: 'click', eventLabel: 'boek-1-demo'});
	});
});

Don’t forget to clear your browser’s cache after adding the code. Let us know how this goes!

2 Likes

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.