Advanced GTM container implementation
All you have to do to implement the Google Tag Manager container code is enter the Container ID and click save.
However, you have some options to customize the implementation which may be relevant to you. The container code is always placed in the <head>
section but you have the option to delay the exceution of the container code.
Why would you do that? Because it may increase the pagespeed but that is not always the case.
The whole idea behind delaying the container code is that when loading af new page the browser is buzy generating the page. Some things are visible to the user and sometings are not. Anything that is not important to be active instantly can be delayed, which will make room for things like generating visual elements.
You have 2 options for delaying the load of the container code. The first option is when the browser fires the requestIdleCallback
event, which is fired when the browser is not buzy. The second opttion is the requestIdleCallback
event plus 2 seconds.
If it is important for you to measere load times in Google Analytics or anything else that requires instant activity you should not delay the container load.
Whether the delay improves the perceived or measured load speed depends entirely on your website so test it!