Closed UcheAzubuko closed 1 year ago
This module is made for Nuxt 3.
For Nuxt 2, you can use google-analytics-module.
Please, add "Nuxt 3" requirement somewhere on homepage. Just wasted some time trying to figure out why this module doesn't work in my project.
Sorry to hear that you ran into the trouble. Generally speaking, you can check compatibility in the Nuxt modules table. I will keep the description as-is. On December 31st, 2023, Vue 2 will reach End of Life (EOL), and Nuxt 2 will follow on June 30th, 2024. Not much time left. I already consider Nuxt 3 the “standard” and intend to keep it that way. 🙂
if anyone needs a library for gtag in nuxt 2, I recommend adding the script link "src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXX" in the head of nuxt.config.js and then create middleware with the code:
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-XXXXXX');
And create some event in middleware gtag('event', 'event_name', {...option})
That way you don't need any libs. The nuxt 2 ones are outdated and don't work.
This module is made for Nuxt 3.
For Nuxt 2, you can use google-analytics-module.
Well that's unfortunate indeed because google-analytics-module is using Universal analytics under the hood it seems and Google is going to shut it down soon. The alternative vue-gtag listed in the thread doesn't work on SSR effectively leaving 0 libraries for Nuxt 2 users who haven't migrated yet
Environment
Local
Reproduction
In Nuxt config:
In Vue File (Nuxt):
Describe the bug
Error when using the nuxt-gtag. Error is - ReferenceError: useGtag is not defined
Please, how can I use the plugin successfully? I keep getting the error.
Additional context
This is a Nuxt project. With the following version numbers:
Logs