
It looks a lot more like the gtag.js snippet now. gtm.js loads through a script tag written straight into the HTML, so the browser can start downloading it earlier.
What changes in the code:
The noscript iframe after the opening body tag is no longer required
The start event uses gtag('js', new Date()) instead of pushing gtm.start to the dataLayer
gtag() is defined inside the snippet, so Consent Mode defaults can be set without extra code
Watch out: if your CMP defines its own gtag(), you may get duplicates.
Watch out: the dataLayer name is no longer a parameter. If you use a renamed dataLayer, add &l=name to the URL and update the variable by hand.
Watch out: with a Content Security Policy using strict-dynamic, the static script needs a nonce or an allowlisted domain.
If you load GTM from your own domain, you only swap the domain in the src. Setups that customized the old function need to be rewritten.
My tip: check Preview mode and confirm your Page View triggers still fire before replacing the snippet in production.
Spotted by Matteo Zambon.


