johannschopplich / nuxt-gtag

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

Destructured method `gtag` is `undefined` #54

Closed 0xecute closed 8 months ago

0xecute commented 8 months ago

Environment

Nuxt 3.3.3 Nuxt-gtag: 2.0.4

Reproduction

Unfortunately I cannot. My project is big and I couldn't reproduce it with minimal example :(

Describe the bug

When trying to use gtag, it is null.

image

Thanks for the help.

Additional context

The network request looks fine: image

modules: [
        '@vueuse/nuxt',
        ['@pinia/nuxt',
            {
                autoImports: ['defineStore', 'acceptHMRUpdate'],
            },
        ],
        '@nuxtjs/i18n',
        '@unocss/nuxt',
        '@nuxtjs/tailwindcss',
        '@formkit/nuxt',
        '@funken-studio/sitemap-nuxt-3',
        '@nuxt/image',
        'nuxt-gtag',
        (_options, nuxt) => {
            nuxt.hooks.hook('vite:extendConfig', (config) => {
                // @ts-expect-error
                config.plugins.push(vuetify({autoImport: true}))
            })
        },
    ],
    gtag: {
        id: 'G-XXXXX',
    },
"scripts": {
    "build": "nuxt build",
    "dev": "nuxt dev",
    "generate": "nuxt generate",
    "preview": "nuxt preview"
  },
"devDependencies": {
    "@iconify-json/fa": "^1.0.1",
    "@iconify-json/ic": "^1.1.3",
    "@iconify-json/logos": "^1.0.4",
    "@iconify-json/mdi": "^1.0.12",
    "@nuxtjs/i18n": "8.0.0-beta.9",
    "@nuxtjs/tailwindcss": "^6.1.3",
    "@pinia/nuxt": "0.5.1",
    "@tailwindcss/typography": "0.5.10",
    "@unocss/nuxt": "^0.58.0",
    "@unocss/transformer-variant-group": "^0.58.0",
    "nuxt": "3.3.3",
    "nuxt-gtag": "^2.0.4",
    "vite-plugin-vuetify": "^2.0.2",
    "vuetify": "^3.5.7"
  },
  "dependencies": {
    "@fawmi/vue-google-maps": "0.9.72",
    "@formkit/icons": "^1.5.9",
    "@formkit/nuxt": "^1.5.9",
    "@formkit/themes": "^1.5.9",
    "@fortawesome/fontawesome-svg-core": "^6.4.0",
    "@fortawesome/free-brands-svg-icons": "^6.4.0",
    "@fortawesome/free-solid-svg-icons": "^6.4.0",
    "@fortawesome/vue-fontawesome": "^3.0.3",
    "@funken-studio/sitemap-nuxt-3": "^4.0.4",
    "@headlessui/vue": "1.7.16",
    "@iconify-json/twemoji": "1.1.5",
    "@mdi/font": "^7.4.47",
    "@nuxt/image": "^1.1.0",
    "@tailwindcss/forms": "^0.5.7",
    "@unocss/preset-icons": "^0.58.5",
    "@unocss/preset-typography": "^0.58.5",
    "@unocss/preset-uno": "^0.58.5",
    "@vueuse/nuxt": "^10.9.0",
    "axios": "^0.26.1",
    "dayjs": "^1.11.6",
    "fast-geoip": "^1.1.59",
    "gpx-builder": "^3.4.0",
    "i18n-iso-countries": "^7.5.0",
    "idle-timeout": "^2.0.1",
    "lodash-es": "^4.17.21",
    "mande": "^2.0.1",
    "moment": "^2.29.4",
    "pinia": "^2.1.7",
    "request-ip": "^3.3.0",
    "swiper": "^8.4.4",
    "vue-loading-overlay": "^6.0.4",
    "vue-select": "^4.0.0-beta.6",
    "vue-toastification": "^2.0.0-rc.5"
  }

Logs

No response

johannschopplich commented 8 months ago

I see you're using an outdated Nuxt 3 version. Please use v3.7+ (available since August 2023). Please upgrade to a newer version. Thanks!

I forgot to add the compatibility version to the module. Fixed now.

johannschopplich commented 8 months ago

Hint: You can use v1, which should be compatible with your Nuxt version.

0xecute commented 8 months ago

Thanks. I thought I had the last version of nuxt, sorry. It works, thank you for the quick answer :)