0

If this has been answered please point me to the solution. I found one post here that is relevant (Onclick Event Tracking Google Analytics Wordpress Visual Composer Plugin) but it says VC 4.12. The site I'm working on is at VC/WPBakery 5.0.1 and it's not working for me. I'm not sure whether I'm doing something wrong (although it seems pretty straight forward) or whether this is a VC/WPB version problem.

I added the appropriate onclick code to the "on click code" field in a Button element on one page as well as an onclick to a Call To Action element on another page. Ex: ga('send', 'event', 'CTA', 'Click', 'Test Event');

Steps I took to troubleshoot:

  1. Opened up Chrome DevTools and enabled Event Listener Breakpoints for mouse clicks under sources then tested both buttons by clicking on them but I don't see anything fire.
  2. Viewed the buttons under "Elements" in DevTools but don't see the onclick code in either. This is the first time I have tried this field. I very seldom use VC but it's on a client site so I'm working with what they have setup.
  3. To further troubleshoot I added a Raw HTML element to the same page as one of the buttons and added another onclick to a URL (onClick="ga('send', 'event', 'CTA', 'Click', 'Test Event 2');". I can see it in DevTools under Elements and I can see it firing in the Event Listener. This one is behaving as expected.

Google Analytics isn't picking up the events on these buttons either. I've been fiddling with this on and off for a couple days thinking I was doing something wrong. I added the Raw HTML element today so most likely won't see anything in Analytics until tomorrow but I'm sure that onclick URL will work.

Does anyone have experience with these in VC/WPB 5.0.1? Is it broken in this version or do I have to add the code differently such as removing the ga and brackets so only the variables are in this field?

Thanks!

Karen
  • 23
  • 1
  • 6

1 Answers1

0

You need to used new GA code if your site is not using the old ga.

gtag('event', 'click', {
                      'event_category': 'Your Catergory'
                    }); 
Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
Siya
  • 1