vue-gtag
vue-gtag copied to clipboard
Using in Nuxt 3 project. `page_view` works, but `event` doesn't
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 Hey bro, maybe u need to use query instead event.
import { query} from 'vue-gtag'
const addToCart = () => { query('event','add_to_cart', {...}); }
I meet the same problem, nothings happened in the GA Events
Update: Now I no longer have this issue