MatteoGabriele / vue-gtag-next

Global Site Tag plugin for Vue 3 (gtag.js)
MIT License
44 stars 3 forks source link

No global object when calling "pageview" #15

Open muttering-oldman opened 3 years ago

muttering-oldman commented 3 years ago

Good afternoon! From time to time I get an error when I try to call the "pageview" function. The error looks like this:

Uncaught (in promise) TypeError: window[globalObjectName.value] is undefined
    query vue-gtag-next.esm.js:110
    event vue-gtag-next.esm.js:151
    pageview vue-gtag-next.esm.js:186
    ...

This seems to happen when gtag script hasn't loaded yet and there is no global gtag object. The error is floating because sometimes the script has time to load before the "pageview" function is called.