Onclick Event Tracking Visual Composer/WPBakery not working in onclick code field - onclick

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:
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.
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.
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!

You need to used new GA code if your site is not using the old ga.
gtag('event', 'click', {
'event_category': 'Your Catergory'
});

Related

Is it possible to see what links are clicked on a particular page without using GTM

I have a page with a lot of links. I would like to determine if it is worth keeping all of them or removing those that users don't click on. So I would like to see what links are clicked on a page. Is this possible without Google Tag Manager?
You can set an event on click on each link with code in page, without GTM, so you can use i.e. a JavaScript function onclick.
See the documentation for event syntax (for gtag.js): https://developers.google.com/analytics/devguides/collection/gtagjs/events

GA not displaying pageView dataLayer event

For some reason Google Analytics only shows the current active page on refresh. Not if I click through the site without refreshing.
If I inspect my website using Google Tagmanager preview I can see the dataLayer push, however it is not visible in Google Analytics..
image from dataLayer
image from GA tag added to GTM
Anyone know what the problem could be?
In you tag you are using the trigger 'all pages',this obey to the dataLayer {'event':'gtm.js'} while i see that you are pushing {'event' : 'Page View'}. If you see the debugger in both case you will see the Pageview as out put, but on the back, they are 2 differents things
The solution is to create a new trigger that obey to the event 'Page View' and use both triggers.
Greetings

Google Analytics: Event not triggering conversion goal

So, I have an event firing when a mailto link is clicked, which is working fine:
Then I added a goal, with the properties of the event. (I should probably mention this was already in place, I didn't just add it after firing the event). I successfully verify it should work:
...But the conversion goal just isn't getting hit:
Screencast here: https://youtu.be/VClrTtVeizw
Am I doing something wrong? The fact it verifies makes me think not but I'm not a seasoned Analytics user so any advice would be great.

Using Google Analytics Event Click on .NET LinkButton not working

I am trying to use Google Analytics on my VB.NET link button on OnClientClick. It is not working. Other pages on my site using same function with straight anchor links (meaning no .NET controls) do capture the event. The only difference I can tell is that .NET automatically encodes the single quote. I'm told browsers should be able to handle this, but it's not working on my page. I've also looked at all the documentation on how .NET started doing this in v 4.0 and there's no real workaround for getting it to NOT encode single quotes. I've tried the suggestions out there with creating custom encoding class and adding a reference in web.config. That didn't work for me. I got a blank page on my site.
Is there any other way I'm not thinking of to successfully track Google Analytics click event on my VB.NET (v 4.5) pages?
I'm adding the event successfully in code behind:
lnkViewAll.OnClientClick = "ga('send', 'event', 'View All Awards', 'click', 'Landing Page - Awards');"
I don't get any errors on my page. It just doesn't successfully capture the click event in my Google Dashboard.
This is how the page renders. Which I'm told browsers should be able to handle html encoding...
<a onclick="ga('send', 'event', 'View All Awards', 'click', 'Landing Page - Awards');" id="lnkViewAll" class="button-text" href="javascript:__doPostBack('lnkViewAll','')">View All Awards</a>
Again, please note, I did research the other solutions out there, particularly this one (https://forums.asp.net/p/1554455/3818604.aspx) and the solutions provided there did not work for me. Any other creative solutions to get this working? I'd have to imagine there are other people out there using VB.NET and Google Anayltics click events.
Your click produces form POST request and the page is unloaded immediately so ga('send'... has no time to perform. instead handle Analytics event on server side (in lnkViewAll_Click handler). Something like this (in VB):
ScriptManager.RegisterStartupScript(Me, Me.GetType(), "gaEvent", "ga('send', 'event', 'View All Awards', 'click', 'Landing Page - Awards');", True)
Another option is to place your LinkButton inside UpdatePanel.

Custom Event Not Firing in Google Tag Manager

I am trying to fire a custom event in Google Tag Manager for a Virtual Page View. I want to be able to track a conversion in a dynamic shopping cart page where the actual URL does not change.
I added the following code for a dataLayer and set it up to fire when the event= VirtualPageView but it's not working.
Any ideas?
dataLayer.push({
'event':'VirtualPageView',
'virtualPageURL':'/thankyou',
'virtualPageTitle':'Thank You'
'conversionValue':'value'
'currencyCode':'currency'
});
Google Tag Setup
Custom Event Setup
Looking at your code I see a lot of missing commas after everything but the second line. This will cause the JS to fail which means no event is pushed into the dataLayer which means GTM won't see anything happening and therefore not fire any tags.
I.e. add a comma after 'virtualPageTitle':'Thank You and after 'conversionValue':'value'. Keep in mind that if you actually pass 'value' as a string and an AdWords Conversion Tag looks for a float, it will fail that tag.
GTM is fairly finicky and will just stop execution when JS code related to it fails.

Resources