Google Analytics Events Tracking not working - google-analytics

I've being tried to install google events tracking on several sites but with no luck. I really want to know why its not working.
I installed events tracking on this site http://bedsndrinks.com/, the second "Book Now" button, here is the code I added to the button onClick=”ga(‘send’, ‘event’, ‘book form’, ‘click’, ‘book now’);“
I tried to use Google Analytics Debugger, but I don't see any "event" hitType. one thing I noticed is that the tracking code looks okay in source code but different when I inspect it in Chrome.

You need to check how your onclick is being rendered. When I loaded the page I saw the following:
<input id="sendBook" type="submit" value="Book Now"
onclick="”ga(‘send’," ‘event’,="" ‘book="" form’,="" ‘click’,="" now’);“="">
As you stated in your question, the format should be as below:
onclick="ga('send', 'event', 'book form', 'click', 'book now');

Related

Google Analytics - Events data not reflecting

In my website we have a banner which on clicking directs the user to our client's website. In order to track the number of people clicking the banner we decided to make use of the google analytics events component. I added the JS provided by them just below my Google analytics script.
var captureOutboundLink = function(url) { ga('send', 'event', 'outbound', 'click', url, { 'transport': 'beacon', 'hitCallback': function(){document.location = url;} }); }
Then in the place of the banner I called the function
<a href="https://example.com/pg/" onclick="return captureOutboundLink('https://example.com/pg/');">
<img src="https://www.moreexample.com/admin/banner/mascot.jpg" alt="macott2022" title="macott2022" class="img-res innerbann" />​
But the google analytics events tab is still not tracking. I tried clicking the Banner few times but it shows no signs of activity. Does it take time to reflect ?
​
yes, events report might need some time to process the data. you can use "events" section of real-time report instead.
moreover you might use Tag assistant or other GA debugging tool to make sure that your event data being sent.

Google Tag Manager tracking drop down menu/list (Web app built in R-Shiny)

I have a R Shiny app that I have connected to Google Analytics using Google Tag Manager (R Shiny app means AJAX website). I am currently tracking the standard stuff like PageViews, and have set up a tag to track which Tab a user clicks on (Using Click Element).
In most tabs, I have a drop-down menu/list (can be seen in the picture). When clicking on this list to select/change the input, the click element does not fire. So clicking does not work here.
In the same picture, I have included the source html code. I highlighted what I think is important. The default input is "Age Group (Discrete)." The "option value=" and "selected" changes the input (changed to "Pyramid (Discrete)"). And it also changes in the div class="item" data-value=..." line.
I do not know how to capture when a user changes the input using Google Tag Manager. I am however able to successfully track this if I put this GA code in my JavaScript file.
$(document).on('change', 'select', function(e) {
ga('send', 'event', 'widget', 'select data', $(e.currentTarget).val());
});
But the above only works if I also have this included:
ga('create', 'UA-######', 'auto');
ga('send', 'pageview');
Which means it is double-counting pageviews (tracking page-views on GTM and the GA code above).
I prefer to track what I want using just GTM. Any help would be appreciated. Let me know if the image is hard to see (May need to zoom in). Thanks
one possible solutions is using GTM custom events:
1) adjust your code to trigger custom event instead of sending GA event:
$(document).on('change', 'select', function(e) {
dataLayer.push({
'event': 'widget data selected',
'selected_value': $(e.currentTarget).val()
});
});
This will trigger specific widget data selected select that can be catched with Custom Event Trigger. Then just use that trigger for your regular Analytics Event GTM tag.
Additionally, you might set up user-defined Data Layer variable to read the selected option value from dataLayer and use it in your tag.

Google analytics Event tracking with an onclick=$('link')

I'm trying to add event tracking to my two buttons, but my button code looks like the following. I'm popping the user down to the section they clicked and hiding the other button's section:
<button class="btn btn-primary btn-lg" onclick="$('#order-form').show();$('#digital-download').hide();location.href='#Print'">
Order Print
Version
</button>
Anyone know how would I add the GA tracking code?
// Form Tracking for Google Analytics
$('.form-track').click(function(e){_gaq.push(['_trackEvent', 'Form', 'Completions', 'Form_'+$(this).attr('title')+'_'+location.href]); });
You can try something similar to this, adding the following code to your buttons:
$('.btn.btn-primary.btn-lg').click(function(e){
ga('send','event','your_category', 'your_action',$(this).text().trim());
})
When the button is clicked, it will send the event with your specified category, action, and the button text as the label. Note that you are using UA, so the event tracking syntax in your example is incorrect.

Did I implement this Google Analytics Event Tracking Correctly?

Did I implement this event tracking correctly? I want to measure clicks on a call to action at the bottom of a blog post:
<a href="http://marketingcuriosity.com/download-a-350-page-ebook-about-digital-analytics-for-free/" onclick=”_gaq.push([‘_trackEvent’, ‘CTA’,’click’, ’red-button’])”></a>
For some reason It's not populating data in my reports.
This is perfectly fine! I would just add a semicollon at the end and make sure you use correct apostrophe in your code
onclick="_gaq.push(['_trackEvent', 'CTA', 'click', 'red-button']);"

google analytics events on links fail on Chrome

I am installing google analytics on some links
javascript:_gaq.push(['_trackEvent', 'category', 'browse', '/hair'])
here's how the link is
<a onclick="javascript:_gaq.push(['_trackEvent', 'category', 'browse', '/hair'])" href="/hair"><i class="icon-"></i>Hair (162)</a>
if I click on the link the push event is not getting recorded.
If I hit the same code from the console then the event is recorded.
NOTE: on Firefox the event are getting recorded properly. So far this only happens on Chrome! :S
Any ideas?
You need the "javascript:" bit only if you put the js in the href attribute (as a protocol designation of sorts). For a click event the javascript method itself will suffice, so your example should look:
<a onclick="_gaq.push(['_trackEvent', 'category', 'browse', '/hair'])" href="/hair"><i class="icon-"></i>Hair (162)</a>
I'm taking a quite educated guess here that FF is more forgiving with the irregular syntax than Chrome. Maybe you can look at the Chrome developer console if this throws an error (or simply fix it and see if things improve).

Resources