I'm using the example ga implementation from the nuxt official website
when I use import router from '~router' and define router.afterEach, I get this error:
[nuxt.js] Cannot load components TypeError: Cannot read property 'afterEach' of undefined
when I use const router = require('~router'), I get this error:
[nuxt.js] Cannot load components TypeError: __webpack_require__(...) is not a function
Question: how to properly import router instance to get google analytics working?
Hi @zzhjerry . Because of new changes to Vue SSR engine, there is no longer a good way using singleton and globals. For GA, you may try google-analytics module which is compatible with 1.x too.
Hi @pi0 it worked! thanks!
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
Hi @zzhjerry . Because of new changes to Vue SSR engine, there is no longer a good way using singleton and globals. For GA, you may try google-analytics module which is compatible with
1.xtoo.