johannschopplich / nuxt-gtag

🔸 Google Analytics & Ads integration made easy
https://developers.google.com/tag-platform/gtagjs
MIT License
298 stars 9 forks source link

Disable tracking while in development #44

Closed hslee2008 closed 7 months ago

hslee2008 commented 7 months ago

Describe the feature

Maybe in nuxt.config.ts, define disableDuringDevelopment module option to disable gtag tracking during development.

I'm not sure if there is any other ways of doing this, so if you know how to disable tracking with another way, please tell me.

Additional information

Final checks

johannschopplich commented 7 months ago

What about you keep the id property if the module configuration empty and add the Gtag ID via a runtime config variable only in production? Does this solve your issue?

// Only add this in production
NUXT_PUBLIC_GTAG_ID=G-XXXXXXXXXX
hslee2008 commented 7 months ago

Oh! I guess that is the best way. Thank you.