gtm-module icon indicating copy to clipboard operation
gtm-module copied to clipboard

Support for Nuxt 3

Open thoth3x opened this issue 2 years ago • 14 comments

Hi,

It seems this plugin doesn't work on Nuxt 3 (v3.0.0-rc.1)

When I run npm run dev it says Cannot start nuxt: Invalid Version: null

Screenshot 2022-05-11 at 15 57 27

My nuxt.config.ts:

Screenshot 2022-05-11 at 15 58 42

Is there any workaround for that or do you planning on updating the plugin to work with Nuxt 3?

Thanks!

thoth3x avatar May 11 '22 13:05 thoth3x

Would be very appreciated indeed. Any alternative until the release of a compatible version ?

copostic avatar May 13 '22 10:05 copostic

The gtm module was updated 2 years ago and doesn't support Nuxt 3. I created a discussion on this topic in case you'd like to comment or follow.

iannngit avatar May 25 '22 07:05 iannngit

@copostic

import { createGtm } from '@gtm-support/vue-gtm'

export default defineNuxtPlugin((nuxtApp) => {
  if (useRuntimeConfig().public.appEnv !== 'production') return
  nuxtApp.vueApp.use(createGtm({
    id: 'GTM-???????',
    defer: false,
    compatibility: false,
    enabled: true,
    debug: true,
    loadScript: true,
    vueRouter: useRouter(),
    trackOnNextTick: false,
  }))
})

acidjazz avatar Feb 05 '23 03:02 acidjazz

Amazing, thanks @acidjazz I wasn't expecting anything anymore from this thread but what a great surprise on this monday morning !

Have a nice day 🌞

copostic avatar Feb 06 '23 09:02 copostic

Amazing, thanks @acidjazz I wasn't expecting anything anymore from this thread but what a great surprise on this monday morning !

Have a nice day 🌞

no problem! make sure its client only: /plugins/gtm.client.ts

acidjazz avatar Feb 06 '23 17:02 acidjazz

@copostic

import { createGtm } from '@gtm-support/vue-gtm'

export default defineNuxtPlugin((nuxtApp) => {
  if (useRuntimeConfig().public.appEnv !== 'production') return
  nuxtApp.vueApp.use(createGtm({
    id: 'GTM-???????',
    defer: false,
    compatibility: false,
    enabled: true,
    debug: true,
    loadScript: true,
    vueRouter: useRouter(),
    trackOnNextTick: false,
  }))
})

After install @gtm-support/vue-gtm I see request to https://vk.com/js/api/openapi.js?169 and https://connect.facebook.net/en_US/fbevents.js

anton-reviakin avatar Feb 18 '23 18:02 anton-reviakin

Are anyone working on this?

niklasfjeldberg avatar Mar 21 '23 20:03 niklasfjeldberg

@niklasfjeldberg https://github.com/johannschopplich/nuxt-gtag

acidjazz avatar Mar 21 '23 22:03 acidjazz

@acidjazz nuxt-gtag seems to be a GA4 library for Nuxt, not GTM one.

iustin-gheorghe avatar Jul 12 '23 09:07 iustin-gheorghe

@acidjazz nuxt-gtag seems to be a GA4 library for Nuxt, not GTM one.

nope, it's GTM. using it now w/ my tag on multiple setups.

acidjazz avatar Jul 12 '23 23:07 acidjazz

@acidjazz nuxt-gtag seems to be a GA4 library for Nuxt, not GTM one.

nope, it's GTM. using it now w/ my tag on multiple setups.

Hi, could you pls provide an example how you are using GTM and GA4 tags in the same time ? Many thanks

GuillaumeDgr avatar Aug 03 '23 15:08 GuillaumeDgr

@copostic

import { createGtm } from '@gtm-support/vue-gtm'

export default defineNuxtPlugin((nuxtApp) => {
  if (useRuntimeConfig().public.appEnv !== 'production') return
  nuxtApp.vueApp.use(createGtm({
    id: 'GTM-???????',
    defer: false,
    compatibility: false,
    enabled: true,
    debug: true,
    loadScript: true,
    vueRouter: useRouter(),
    trackOnNextTick: false,
  }))
})

We have been using this implementation, but the vue-gtm seems only to add the script in the body, en not in the head. Data is received, but not everything is working correctly in GTM. Seems that the script needs to be added to the head as well. Anybody else had this before?

memic84 avatar Nov 17 '23 09:11 memic84

modules: [ '@zadigetvoltaire/nuxt-gtm' ], gtm: { id: 'GTM-ID', enabled: true, debug: false, },

it's working fine

nodeexcel avatar Jan 23 '24 09:01 nodeexcel

@acidjazz nuxt-gtag seems to be a GA4 library for Nuxt, not GTM one.

nope, it's GTM. using it now w/ my tag on multiple setups.

Are you sure it's GTM? Just checking as this suggests otherwise: https://github.com/johannschopplich/nuxt-gtag/issues/13

joeczucha avatar Jan 31 '24 17:01 joeczucha

I have made a drop in replacement for this module - https://www.npmjs.com/package/gtm-nuxt3

NikhilVerma avatar Mar 06 '24 03:03 NikhilVerma