This is a major rewrite of @nuxtjs/google-tag-manager after 3 years of contributions and feedback from users.
🍴Package Rename
For more simplicity package renamed from @nuxtjs/google-tag-manager
to @nuxtjs/gtm
👍 Native Behaviour
Previously, the module was using custom code to inject gtm.js
via a nuxt plugin. It was causing several problems as everything was deferred until nuxt bundle loads and starts executing client-side plugins. Starting with v2, we directly render official snippets with few tweaks into HTML pages (both SSR and SPA)
🔒 Respect User Privacy
By default respectDoNotTrack
option is enabled which also guards snippet execution. You can also optionally disable autoInit
to first ask users and then manually call $gtm.init()
(all previous events will be buffered so there is no data loss). Also using a polyfill for maximum browser support for doNotTrack
🦄 Breaking Changes
query
(andenv
) renamed tovariables
respectDoNotTrack
enabled by defaultnoscript
(<iframe>
fallback) disabled by default ~> Will be enabled by default starting 2.2.0google-tag-manager
option innuxt.config
should be changed togtm
pushEvent
andpushData
merged into$gtm.push
with less strict object checks
💖 Huge thanks to v1 contributors
@williamchong007 @igtm @syffs @phlogisticfugu @Manfies @McSneaky @matteo-rigon @derz @chrisladams @zsavajji @gnuletik