Pro Theme Buttons and onClick GA Events

I am trying to implement GA event tracking on a few Pro Theme buttons. I have gathered that I should add a class to the specific button and then add a script in Pro Theme’s main Theme Options JS. Can anyone help with the script that needs to be dropped in main theme options JS area? If it helps, here is what I included in another site’s HTML:

onClick=“ga(‘send’, ‘event’, ‘button’, ‘click’, ‘incfile’);”

Hello Zac,

Thanks for asking. :slight_smile:

Please take a look a the solution mentioned in following thread:

Thanks.

I saw that conversation. I replaced the word “download” with “button” and replaced the eventLabel, but could not get it to work. I assumed that the word “document” in the first line may need to be updated since my users are not downloading anything, but rather just clicking on a call to action button. Thoughts?

Hi,

Did you add ga_event class on your button elements?

You need to add that class for the js script to work.

Can you provide us the url of the page where we can see the issue so we can take a closer look.

Thanks

Yes, I added that class to the “Go to IncFile” buttons on this page: https://www.llcreviews.com/evaluations/incfile-review/

I then added this script to the Global JS:

jQuery(document).ready(function($){
$(’.ga_event’).on(‘click’, function(){
ga(‘send’, ‘event’, { eventCategory: ‘button’, eventAction: ‘click’, eventLabel: ‘buttonclick’});
});
});

Hi Zac,

When loading your referenced URL, I see the following error on the console log.
Loading failed for the <script> with source “https://www.googletagmanager.com/gtag/js?id=UA-xxxxx-xx”.

Then, when clocking on your button, I see the following error on the console log.
ReferenceError: ga is not defined

Could you please try using a third party plugin to install install Google tag manager code and see if that helps (https://wordpress.org/plugins/duracelltomi-google-tag-manager/).

Let us know how it goes.
Thanks!

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