Why is Google Analytics Reporting Real Time Events? - google-analytics

I'm not seeing any events in GA Realtime reporting after implementing below code for GA Event tracking... Standard Pageviews reporting has been working fine for since I implemented last month, the issue is just with "Events".
I tried to follow the instructions per https://developers.google.com/analytics/devguides/collection/analyticsjs/events#overview.
This is a screenshot of my Chrome Dev Tools Console
https://www.dropbox.com/s/euamp6bz87qh6g9/Screenshot%202016-06-04%2018.33.19.png?dl=0
This is a screenshot of my Chrome Dev Tools Network:
https://www.dropbox.com/s/71lqmv492pquk1x/Screenshot%202016-06-04%2018.31.56.png?dl=0
Script in HTML before end tag with my UA number here noted as Xs/Y - i am using a server side with this code for each page:
<!-- Google Analytics -->
<script>
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
ga('create', 'UA-xxxxxxxx-y', 'auto');
ga('send', 'pageview', 'event');
</script>
<script async src='https://www.google-analytics.com/analytics.js'>
</script>
<!-- End Google Analytics -->
<!-- HTML Code -->
<ul>
<li>Download DICENTIS Wireless A & E Specifications</li>
</ul>
Any feedback on what I could be doing wrong would be much appreciated!
This is my edited and now working code based on feedback received:
<!-- HTML Code -->
<ul>
<li>Download DICENTIS Wireless A & E Specifications</li>
</ul>

If you are seeing pageviews and not events, then it's not really a matter time and waiting for the events to be processed, but probably something to do with your code or implementation. I am seeing a potential issue with the onclick code, however:
ga('send', 'event', 'download', 'click', ‘Download DICENTIS Wireless A & E');
Your event label is using a smart quote rather than a straight quote. When I paste the event code into the console, I get an error message, so you should change the ‘ to a ' and make sure they are all straight quotes.
Also, when you are sending your pageview with ga('send', 'pageview', 'event'), I'm not sure if you are aware, but you are changing the page path from the default of whatever is normally sent with the pageview, to event. So in your reports, you would see a page path for your pageviews of event.

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.

Value not passing to Facebook using GTM

I have a tag that sends purchase event to Facebook that looks like this:
<script>
fbq('track', 'Purchase', {
value: {{reservationValue}},
currency: 'ILS',
});
</script>
The reservationValue is a variable that the GTM gets from the page before the tag is fired.
For some reason, when i'm using the preview mode, I see that the HTML code that is sent to Facebook is:
<script type="text/gtmscript">fbq("track","Purchase",
{value:google_tag_manager["GTM-XXXXXXX"].macro(2459),currency:"ILS"});</script>
screenshot here
The same variable is used to send value of purchase to AdWords and when I preview the AdWords tag, the value is passing as it should.
I did Tag Sequencing and fired the pageview Facebook pixel before the purchase tag.
Any suggestions?
Thanks
I think this is normal behaviour because the syntax of GTM variables with the double curly brackets is the GTMs own syntax. what you saw there happens to every GTM variable. The GTM variables get "translated" to regular javascript again.
If you open the console within a browser and type in "google_tag_manager["GTM-yourContaienrId"].macro(2459)" you should be able to se the value assuming the Tag has been fired of course. You could also console.log the variable to see if it is being filled correctly.
The reason why you didn't see that behaviour on the AdWords tag is probably because it is a "native" tag type in the GTM and the other one is just plain html.
Change into:
<script>
fbq('track', 'Purchase', {
value: '{{reservationValue}}',
currency: 'ILS',
});
</script>

Google tag manager don't do analytics

I have Google tag manager tag inserted on all pages on the website.
head:
<!-- Google Tag Manager -->
<script>
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','GTM-XXXXX');
</script>
<!-- End Google Tag Manager -->
At the end of body:
<noscript>
"<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MDKNR5" height="0" width="0" style="display:none;visibility:hidden"></iframe>"
</noscript>
On homepage and four other pages on website, this code works OK
On those pages, gtm head element (I suppose), creates two new lines above him.
<script type="text/javascript" async="" src="https://www.google-analytics.com/analytics.js"></script>
<script async="" src="https://www.googletagmanager.com/gtm.js?id=GTM-XXXXXX"></script>
But on two remaining pages, only one line is created
<script async="" src="https://www.googletagmanager.com/gtm.js?id=GTM-XXXXXX"></script>
I went deep in that gtm.js file and found:
if (!Ck) {
var Z = a[oc] ? "u/analytics_debug.js" : "analytics.js";
a[kd] && !a[oc] && (Z = "internal/" + Z);
Ck = !0;
r(L("https:", "http:", "//www.google-analytics.com/" + Z, u), function() {
x[l()].loaded || d()
}, d)
}
That returns false, and don't do that part of code. So, I don't have analytics on that page.
Chrome extension "Google Tag Assistant" gives me this notification:
This page did not send a hit, but other recorded pages on the same
domain did send hits. Most likely, this page was not properly tagged
with the Google Analytics tracking code
In the end, to mention, I don't have access to that Google account, I only got tracking codes for GTM and analytics.
If the tracking code for Google Analytics should fire or not is set within the GTM interface. If, for some reason, there is a blocking trigger set to not fire Analytics on those pages, that is the most likely reason. It is basically impossible to answer your question without access to the configuration itself or more information from the GTM account and the way it is set up.

Google Analytics Events No Longer Working In Universal Analytics & GTM

I had a script using the older Google Analytics tag that was directly embeded on my page. This script fired an event when it detected that ad block was being used:
<!--AB Check-->
<script type = "text/javascript"
src = "http://example.com/JS/Ads3.js"> </script>
<script type = "text/javascript" > jQuery(document).ready(checkAds());
function checkAds() {
if (document.getElementById('adsense') != undefined) {
document.write("<script>_gaq.push(['_trackEvent', 'Adblock', 'Unblocked', 'false',,true]);</sc" + "ript>");
} else {
document.write("<script>_gaq.push(['_trackEvent', 'Adblock', 'Blocked', 'true',,true]);</sc" + "ript>");
}
} </script>
<!--End AB Check-->
Recently I moved my Google Analytics tag to Universal Analytics and Google Tag Manager. At that time my script broke and no longer records these events.
How can I update my adblock script to be compatible with Universal Analytics and GTM?
If you weren't using GTM, then you need to change the event tracking code to use the ga function:
ga('send', 'event', 'Adblock', 'Unblocked', 'false', {nonInteraction: true});
ga('send', 'event', 'Adblock', 'Blocked', 'true', {nonInteraction: true});
More information about this event tracking code can be found here: https://developers.google.com/analytics/devguides/collection/analyticsjs/events
But since you are using GTM, what you could do is to create your event tag that is fired via custom JS trigger that returns a boolean, depending on the conditions for checking the adSense ID.
I ended up using this article http://dcarlbom.com/google-tag-manager/measure-how-many-of-your-visitors-that-are-using-adblock to set the event tracking up for GTM.
Thanks #nyuen for explaining how to do this using the ga function, but unfortunately this won't work for folks using GTM.

Google Anlytics event not firing

I am not getting and event data in GA. I installed Google Analytics Debugger Chrome extension and I see nothing happening (same goes when looking at Network panel in developer tools). I Googled it and read many (many) other answers and it looks like I'm doing things right. Page views, etc. are registering correctly...
I have this code as the last thing before my closing tag:
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-MYREALCODE', 'mybna.net');
ga('send', 'pageview');
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-MYREALCODE']);
_gaq.push(['_trackPageview']);
</script>
My event handlers are done using jQuery, all inside an external js file, loaded before the closing tag. For example:
$(function () {
$('#show-less').click(function (e) {
pbr.showHideMore(e);
_gaq.push(['_trackEvent', 'ShowMore', 'Hide', 'top button']);
});
});
Any ideas anyone?
Edit: I keep deleting and undeleting this anwswer because I'm not sure if your code is redundant or if you are actually trying to send data to two different properties.
If it's the first, see original answer below. For the latter make sure that you account/property-Ids are pointing to correctly configured properties (i.e. the first UA, the latter asynchronous), plus I'm pretty sure you need to include the ga.js liberary two if you want the methods pushed in the array to be executed.
You are mixing Universal Analytics and asynchronous code, that's not going to work (i.e. if you have ga send and _gaq.push in the same piece of code you are most probably doing it wrong). Adapt your event tracking code for UA and you should be alright.
Try wrapping the click listener in a document ready function:
$(document).ready(function(){
$('#show-less').click(function (e) {
pbr.showHideMore(e);
_gaq.push(['_trackEvent', 'ShowMore', 'Hide', 'top button']);
});
});
I often find that the listener won't link up until the DOM is fully loaded. Sometimes it does, though, but that might have to do with the code being below the object in question in the code.
It always helps me to put an "alert" into the click function while testing to be sure it's actually firing off (and catching) that event.

Resources