vue-gtag icon indicating copy to clipboard operation
vue-gtag copied to clipboard

Using in Nuxt 3 project. `page_view` works, but `event` doesn't

Open YosefMets opened this issue 2 years ago • 2 comments

Environment *

npm ls vue-gtag: [email protected]

npm ls vue: [email protected]

Description *

import VueGtag from 'vue-gtag'

export default defineNuxtPlugin((nuxtApp) => {
  nuxtApp.vueApp.use(VueGtag, {
    config: {
      id: 'XXX-XXXXXX',
    },
  }, nuxtApp.$router)
})

page_view works. Then I try use event in the setup:

import { event } from 'vue-gtag'

const addToCart = () => {
  event('add_to_cart', {...});
}

Expected behavior

When I'm adding item to cart nothing's happened in the Googlу Analytics. There is also no new request in the "Network". But in window.dataLayer added a new data ['event', 'add_to_cart', {…}, ...]

What am I doing wrong?

YosefMets avatar Jan 10 '23 14:01 YosefMets

@YosefMets Hey bro, maybe u need to use query instead event.

import { query} from 'vue-gtag'

const addToCart = () => { query('event','add_to_cart', {...}); }

dizao avatar Feb 08 '23 15:02 dizao

I meet the same problem, nothings happened in the GA Events

Update: Now I no longer have this issue

howard-tzw avatar May 02 '23 03:05 howard-tzw