Google analytics double counting events - google-analytics

I have a page in my site "x" that redirect to another site "y".
So I wanted to track that redirect traffic and send it to Google analytics,
by this code :
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
(function(url) {
gtag('event', 'y', {
'send_to': 'UA-xxxxxxxx-x',
'event_category': 'out',
'event_label': url,
'transport': 'beacon',
'event_callback': function(){document.location = url;}
});
})("<?php echo $url; ?>");
When I go to see the Events in Google analytics for "X" I found 5000 event sent.
when I go to see the Referral Traffic in Google analytics for "y" I see only count 2500 mean half the traffic.
These analytics has the same time zone and the date.
So what cause the problems that make double counting the Events?

You're comparing two different metrics (events and users probably). One user can be redirected a million times and it will be still counted on the site Y as 1 user if it happens in one day.
The best QA is to open both sites' real-time analytics and execute the redirect with a parameter which will make sure you're watching your action. Then you should see an event hit on site X and a pageview on site Y.

Related

Google Analytics is showing "Avg. Page Load Time" always as Zero

My google analytics script is like this
< !--Global site tag(gtag.js) - Google Analytics-- >
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-xxxxxxx-x"></ script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-xxxxxxx-x', { 'page_path': curpath });
</script>
Thiw works fine except Avg. Page Load Time is not getting logged in analytics (always shows as zero). What am I missing here?
Note: My site works on ajax calls with single URL
You are missing the necessary information from the browser, since you use AJAX calls.
Google Analytics uses the Navigation Timing API, which is quite reliable, since the actual measurement is done by the browser and the values can be read as properties of the window.performance.timing object.
Example from here:
Calculate the total page load time
const perfData = window.performance.timing;
const pageLoadTime = perfData.loadEventEnd - perfData.navigationStart;
Your Ajax call does not populate those values (which in a way makes sense, since the corresponding DOM events are not populated in an AJAX call), so GA cannot log a page load time.
You can do custom user timings in GA. They will be limited to a sample of 1% of your calls max, and your averages will be extrapolated from there. You would pass in the delta between the start of your Ajax call and the point at which the response is rendered.

Google Analytics showing partial data in magento

Have just done a migration from 2.2.2 to 2.3.3.
Initially once migration was completed, no data at all was recording in google analytics screen.
We the checked Analytics setting in the backend of the store:
Stores>Configuration>Sales>Google API>Google Analytics
It was disabled so we enabled it.
Prior to migration, daily new users: 500.
After migration, daily new users for the last 2 days: 140.
Conversions: unaffected
Conclusion: analytics is not recording the data correctly.
Can anyone advise what else could be investigated why the data isn't accurate after 48hrs+?
and I can see also some google code in:
public_html/app/design/frontend/[vendor name]/[theme name]/Magento_Theme/templates/html/footer.phtml
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXXX-X"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-XXXXXXX-X');
</script>```
The code is the standard one (it shouldn't be in the footer but in the header) and it track the pageviews, if it is in all pages you should have no user or session detection issues. Check if it is present on all pages. In addition, on the purchase confirmation page there must be the transaction code in addition to the one you entered here.

Google Analytics with too low of bounce rate

I'm looking for some assistance here. We're seeing a very low bounce rate (3%) which i know can't be possible.
The analytics appears to be setup incorrectly on our site. We see a lot of event tracking that happens automatically so i'm pretty sure this is our problem. Here is the code we're seeing that was implemented in what looks to be twice. Which do we need to get rid of?
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-xxxxxxx-
1`enter code here`"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-xxxxxxx-1');
</script>
Any help is appreciated.
Thanks,
gr8rck
The snippet you've provided looks fine. If the same set of code has been provided twice, remove one of the instances.
You mentioned that a series of events fire automatically. This is most likely what is causing an artificially low bounce rate.
If these events fire without user involvement, my suggestion is that you define them as non-interaction events. The events will still record, but will not count as a true user interaction. Therefore your bounce rate will be unaffected.
You would send a non-interaction event like so:
gtag('event', 'my_event_action', {
'event_label': 'my_event_label',
'event_category': 'my_event_category',
'non_interaction': true
});

Google analytics Goal URL destenation?

I have to set a goal after user successfully signed up
I don't send user to "successful signup page.html" , User returns to dashboard , I read that GA can read Parameters in URL, but does it read fragments ?
as I use fragments on my website can I use (/dashboard#Success) as my destination to count success goal ?
or only parameters that can be red (/dashboard.html?signup=success)
Google analytics, as you've already pointed out, disregards fragments, but you can still override the default URL to include the fragment in your page views so that your goals will still work:
ga('send', 'pageview', {'page': document.location.pathname + '#' + document.location.hash})

Google Analytics: can I combine trackEvent and trackPageView into a single call?

I am combining Google Analytics' _trackEvent and _trackPageview into a single call, like the following:
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-20822178-2']);
_gaq.push(['_setCustomVar', 1, 'My Custom Page View Variable', 'My Value']);
_gaq.push(['_trackEvent', 'My Category', 'My Action']);
_gaq.push(['_trackPageview']);
[...GA snippet insertion...]
This generates two __utm.gif requests to Google. This would be okay except that the request with the _trackEvent information ALSO contains the CustomVar info, which leads me to believe that Google counts the pageview on BOTH requests. I don't want to double count my page requests... so is Google smart enough to throw away the pageview info sent with the _trackEvent call?
Thanks!
It won't double count page views but it is double counting your custom var. If you don't want that, reorder the pushes, make the trackpageview come first, then the custom var, then the event

Resources