-
Notifications
You must be signed in to change notification settings - Fork 85
Disable bundling for Google Tag Manager #687
Description
📚 Is your documentation request related to a problem?
I'm honestly not sure if this is a bug or just something that needs to be mentioned in the docs.
I was trying to disable the bundling on the Google Tag Manager not to bundle into my application (for the marketing team 🙃 ) and I was trying to follow the docs for it described here: https://scripts.nuxt.com/scripts/google-tag-manager#first-party-mode
But when checking the network tab, i was still seeing it being delivered from the assets. After some debugging and consulting claude, "we" came to the conclusion, that the problem is that i was accessing the proxy in my app as well to log events into the dataLayer object.
Turns out, that you have to set the bundle: false script option in every occurence, otherwise it will just bundle it as it's the default in the composable as well.
So in my app, it looks loke this now:
// nuxt.config.ts
scripts: {
registry: {
googleTagManager: {
id: "GTM-XXX",
bundle: false,
},
},
},<script lang="ts" setup>
// app.vue or any other .vue file
const { proxy: gtmProxy } = useScriptGoogleTagManager({
scriptOptions: { bundle: false },
});
useScriptEventPage(({ title, path }) => {
gtmProxy.dataLayer.push({
event: "pageview",
title,
path,
});
});
</script>So either this should be in the docs or, what I would have expected, is that the bundle option should be passed down from the registry to the instances. This is the case for the id for example and a probably a couple of other options.
Thanks and hope this helps anyone if they have the same issue!
🔍 Where should you find it?
If this is only a doc change, i would expect it here with a headsup warning: https://scripts.nuxt.com/scripts/google-tag-manager#first-party-mode
ℹ️ Additional context
No response