MatteoGabriele / vue-gtag

Global Site Tag plugin for Vue (gtag.js)

Home Page:https://matteo-gabriele.gitbook.io/vue-gtag/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

YosefMets opened this issue · comments

Environment *

npm ls vue-gtag: vue-gtag@2.0.1

npm ls vue: vue@3.2.45

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?

commented

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

import { query} from 'vue-gtag'

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

commented

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

Update: Now I no longer have this issue