Closed chester-af closed 1 year ago
Doesn't look like you have it installed it yet on that reproduction link. you might want to check it again properly
For me it is that useGtagConsent(true) does not add gtag script to the head when the nuxt.config.ts looks like this:
gtag: { initialConsent: false, },
And .env file looks like this:
NUXT_PUBLIC_GTAG_ID=G-XXXXXXXXXX
If I add ID to nuxt.config.ts then it works:
gtag: { id: 'G-XXXXXXXXXX' initialConsent: false, },
But it seems that the issue is when running in production, when running npm run dev
, it seems that everything works just fine.
This feature has been added in the latest release of Nuxt Gtag! You can now omit the id
in your Nuxt Gtag module options and use useGtagConsent
to pass a custom Gtag ID. If Gtag hasn't been initialized yet, it will be.
Environment
Darwin
v19.9.0
3.5.2
2.4.1
yarn@1.22.19
vite
css
,postcss
,runtimeConfig
,components
,modules
,gtag
,lazyLoad
,swiper
,app
,devServer
,vite
,ssr
@pinia/nuxt@0.4.11
,nuxt-swiper@1.1.0
,@vue-macros/nuxt@1.3.11
,nuxt-lazy-load@3.0.4
,nuxt-gtag@0.5.7
-
Reproduction
https://stackblitz.com/edit/github-vihbux?file=app.vue
Describe the bug
Hello,
When I use the useGtagConsent() function and set it to true after clicking a button, it does not insert the script into the head which means that events aren't sent to Google Analytics. if you place the useGtagConsent(true) in onMounted of the component, it will insert the script into the head though but I only want to insert the script if the user clicks an accept button.
Additional context
No response
Logs
No response