
The new code looks much more like the gtag.js snippet. Here is what changes:
gtm.js now loads through a script tag written straight into the HTML, so the browser can start downloading it earlier
The noscript iframe after the opening body tag is no longer required, so the install is just the head code
The start event now runs through gtag('js', new Date()) instead of pushing gtm.start to the dataLayer
gtag() is defined inside the snippet, so the Consent Mode default can be set without extra code
Watch out: if your CMP defines its own gtag(), you may end up with a duplicate.
For setups with a renamed dataLayer, the name is no longer a parameter. Add &l=name to the URL and update the variable by hand.
With a Content Security Policy using strict-dynamic, the static script needs a nonce or an allowlisted domain.
Loading GTM from your own domain, for example with Stape's Custom Loader? Just swap the domain in the src. Setups that customized the old function need a rewrite.
My tip: before replacing the snippet in production, check in Preview mode that your Page View triggers still fire.
Spotted by Matteo Zambon.


