cajames / vue-tag-manager

Simple Google Tag Manager implementation for Vue
19 stars 3 forks source link

document is not defined, $not found #15

Open kfbsp opened 4 years ago

kfbsp commented 4 years ago

I get following error in console:

Uncaught ReferenceError: $ is not defined at :1:228 at :1:301 at gtm.js?id=GTM-PGG34N8&l=dataLayer:490 at c (gtm.js?id=GTM-PGG34N8&l=dataLayer:492) at Bb (gtm.js?id=GTM-PGG34N8&l=dataLayer:353) at e (gtm.js?id=GTM-PGG34N8&l=dataLayer:382) at gtm.js?id=GTM-PGG34N8&l=dataLayer:342 at Array. (gtm.js?id=GTM-PGG34N8&l=dataLayer:383) at Object.pg (gtm.js?id=GTM-PGG34N8&l=dataLayer:382) at lf (gtm.js?id=GTM-PGG34N8&l=dataLayer:383)

and while compiling:

WARN [vue-tag-manager]: document is not defined
at createScriptTag (node_modules\vue-tag-manager\lib\index.cjs.js:93:21) at getScriptTagWithContent (node_modules\vue-tag-manager\lib\index.cjs.js:117:21) at Object.install (node_modules\vue-tag-manager\lib\index.cjs.js:151:33) at Function.Vue.use (node_modules\vue\dist\vue.runtime.common.dev.js:5087:22) at Module../src/plugins/tagManager.ts (server.js:4261:44) at webpack_require (server.js:21:30) at Module../.nuxt/index.js (server.js:1002:90) at webpack_require (server.js:21:30) at Module../.nuxt/server.js (server.js:1362:67) at webpack_require (server.js:21:30) at Object.0 (server.js:4296:18) at webpack_require (server.js:21:30) at server.js:85:18 at Object. (server.js:88:10) at evaluateModule (node_modules\vue-server-renderer\build.dev.js:9318:21) at node_modules\vue-server-renderer\build.dev.js:9354:17

cajames commented 4 years ago

Ah this must be in a SSR use case, as on the server document won't be defined. I'm writing a mod which will fix this. That's for raising it!