GA4 tags seem to be delayed in firing due to a setTimeout function

Silver Contributor
Silver Contributor

We noticed that our GA4 tags seem to be delayed in firing due to a setTimeout function that is set to 5000 ms. Is the setTimeout function part of the standard GA4 tag template and if so what is the typical default? We have made some changes to get our events firing correctly in our GA4 tag but none that include setTimeout. The setTimeout comes from the GTM script(https://www.googletagmanager.com/gtag/js?id=G-TM0P7DF8JE) that is loaded through our Tealium tag, which we do not have any control over. Any thought on how to fix this? Screenshot 2023-05-19 at 2.39.32 PM.png

3 REPLIES 3

GA4 tags seem to be delayed in firing due to a setTimeout function

Tealium Employee

Hello @anourani111 This used to be a timeout put in place within the GA4 library on Google's side - I believe its their way and waiting to see if there are multiple events that they can batch and send together.

This is supported by their documentation here 

I believe there used to be a way to have this send immediately involving some debug flag, but you probably dont want to enable this in production.

GA4 tags seem to be delayed in firing due to a setTimeout function

Silver Contributor
Silver Contributor

Thank you @LordLingham 

What is the best way to deal with this then? 

GA4 tags seem to be delayed in firing due to a setTimeout function

Tealium Employee

@anourani111 
In production, Im not sure there is anything you can reasonably do to bypass this.
This is part of the "design" with the client-side batching which is generally "best" for the user. If they navigate away the events should still fire.

 

For development / testing, you may be able to use the dev chrome extension which used to bypass the wait.
https://chrome.google.com/webstore/detail/google-analytics-debugger/jnkmfdileelhofjcijamephohjechhna 

Public