How to speed up loading of Google Analytics 4 tracker? - google-analytics

I’ve been experiencing a discrepancy in terms of page views between GA4 and GA3, both installed through GTM page view event.
I notice that GA4 is much slower to send the collect request compared to GA3, literally takes 3-4 seconds more from my office connection and pc.
I think that this is the main cause of discrepancy between the two.
Is it possible to somehow speed up GA4 tracker?

I remembered Google design this feature.
Here is the reference from a blog post
One thing you might have noticed is the delay it takes for the hit to
be sent. When you load the page, you can see how the browser waits a
few seconds before dispatching the hit to GA. This is because GAv2
batches requests automatically, which, again, is a great feature
upgrade.
Link
GA4 now will send multiple event as one request. But you don't need to worry about this will lost some event if user close the browser suddenly.
Here is the article from Google
Note: When a user's device goes offline (for example, a user loses their internet connection while browsing your mobile app), Google Analytics stores event data on their device and then sends the data once their device is back online. Analytics ignores events that arrive more than 72 hours after the events are triggered.
Link

Related

Page load issue with GA4

We have a problem related to execution times are observed related to GA4:
Basically, the page loads so fast that once an action is signalled and, in most cases, GA4 does not have time to execute. We did not see this problem with UA.
With 'Preview Mode'in GTM, GA4 executes as it should do, and so, the information is sent to GA4 servers.
About the "normal" execution: the website behaves way too fast, and so, even though GA4 executes, it does not have enough time to send the information to GA4 servers (pending requests which information does never reach GA4 servers).
We investigated and tested different implementation ways to fix it but the problem is still there.
Any of you have an idea about this?
We also attach the screenshots of the tests carried out:
UA run times, approx. 100-200 ms. - Image 1
GA4 runtimes, approx. 5 seconds - Image 2
GA4 execution times with the GA Debug extension activated, approx. 100-200 ms. - Image3
Many thanks,
Do you still see the issue between UA and GA4?
Based on the google document from GA4, GA4 will use sendBeacon to send events, this is to fix some problems with the old UA using XMLHttpRequest to send events, the problem with the XMLHttpRequest is that if events send during the unload page event, the events might not send by the browser.
Also, depending on the scenarios, most GA4 events will batch together and send from the browser, so if you're in debugging mode, events are sent immediately, that's why you see the time faster.
So, in normal mode, GA4 might send events in delay but it batch events altogher, the good thing is if you go to a different page, the event will continue to fire sine GA4 using the sendBeacon API.
You can also refer to this article from GA4 about event batching for GA4.

Trying to figure out why Google Analyics report more users than our own stack

Comparison is between the Google Analytics script and a "chat widget" loaded in a iframe on the onload event. The iframe is not loaded if the useragentlooks like a crawler. The code in the iframe creates a websocket connection and then a user is upserted in our backend.
I'm looking at one website where we currently get around 2/3 of new users reported by Google Analytics as users in our backend.
With the new Google Analytics UI, it's not clear to me how much crawlers are actually filtered or not (e.g. is Google Analytics always filtering Google Crawler?). That could explain a lot.
Our "tracking id" is saved in localstorage which is a bit more persistent than a cookie, but I can't see it making a big difference.
The extra loading time and the websocket connection can probably explain a bit (old browsers that don't support TLS 1.2, baldy configured proxies, etc) can explain some of it, but 1/3 seems big.
Any insights in Google Analytics metrics or other ideas are welcome.
Bot traffic in Google Analytics is not filtered by default. You can enable it in View Settings.
Also it's possible to pass User Agent strings into Google Analytics as a custom dimension and then create filter to exclude sessions based on User Agents that you know to be bots.
https://www.lunametrics.com/blog/2015/04/01/eliminating-bot-traffic-from-google-analytics-once-and-for-all/
The second reason of difference may be that GA tracker fires when page starts to load, but "chat widget" when window is loaded. Some bounced sessions (and users) are counted by GA, but not counted by "chat widget".

Google Analytics counting sessions/views twice?

A site I work with recently saw a doubling of it's direct traffic as recorded in Google Analytics. There doesn't seem to be a obvious external reason for the increase (like some promotion or something) so I'm looking into a possible technical reason.
When loading the homepage and monitoring Real Time Traffic Sources, I see two hits in rapid succession each time I reload the page.
However I'm using the GA debugger extension in Chrome and it's only showing the two expected function calls: ga('create') and ga('send', 'pageview').
The site has other event tracking set up but each event is wrapped in an event listener in JS so they aren't firing automatically. And if they were they should show up in the GA debugger anyway
So I'm at a loss. I can't think of why this is happening, let alone just for direct traffic as opposed to other sources. Anyone have any ideas?
Thanks!

Google Tag fires but not logged in Analytics

I had set up my Google Tag to track clicks on spans with certain IDs, the events are firing according to WASP extension, but they are not showing up in my Google Analytics account.
Here is my trigger:
My Tag:
WASP in action:
GA displays pageview only:
Code is installed properly
Sorry if this seems pretty obvious, but in Real Time you should be on the Events tab, and it seems you are looking in the Content tab. Events are never displayed there.
While the configuration looks to be correct, remember that events won't show up in your standard reports until the data is processed, which takes about 24 hours. As long as the hit is showing up in your Real-Time reports, then you shouldn't have any issues.
Can you please post full HTTP request? For instance from Charles Web Debugging Proxy of Live HTTP Headers extension or anything simillar.
What you post seems to be correct as #nyuen says!

Q: Deactivation of Google analytics

When I access the page of certain communities of Stackoverflow, it often occurs that for about a minute my computer gets a very high loading and I can't even scroll the page with the mouse. Recently I read at the bottom of the screen that it was waiting for google.analytics.com in that time period.
Is this a normal phenomenon to be expected or could I do something to avoid
that inconvenience?
You can opt out of being tracked by Google Analytics or download a number of add-ons that block network requests for the script, but I highly doubt that would solve your problem.
Google Analytics is loaded asynchronously, so it doesn't block other scripts or affect the performance of anything else on the page while it's being downloaded.
There may be times where the connection is slow or for whatever reason it takes a while for your browser to download the script from google-analytics.com, but if you page is responding slowly and you happen to see that it's waiting for google-analytics.com at the bottom, those two things are likely not related.
What's far more likely is that whatever is causing the request for the Google Analytics script to be slow is also causing the rest of the page to be slow. In other words Google Analytics is not the root of your problem, it's another symptom.
In either case, you can try blocking it just to be sure. Sometimes web developers implement Google Analytics incorrectly...

Resources