I try use vue-analytics. In plugin i need VueRouter instance like this:
import Vue from 'vue'
import VueRouter from 'vue-router'
import VueAnalytics from 'vue-analytics'
const router = new VueRouter({
router: // your routes
})
Vue.use(VueAnalytics, {
id: 'UA-XXX-X',
router
})
Where can I import a router based on the folder structure?
You can read here more about how to create a plugin with nuxt
Plugins Guide
and with example here
Plugin Example
Just do some research and you will figure it out otherwise come back here we can help
Yes, I'm familiar with these materials. However, I do not understand how to access the router instance
@@Have you seen this ? https://www.npmjs.com/package/@nuxtjs/google-analytics
@cawa-93 use context https://nuxtjs.org/api/context and route object like this:
import Vue from 'vue'
import VueI18n from 'vue-i18n'
Vue.use(VueI18n)
export default ({ app, route }, inject) => {
// Set `i18n` instance on `app`
// This way we can use it in middleware and pages `asyncData`/`fetch`
app.i18n = new VueI18n({
/* `VueI18n` options... */
})
}
you can look here too: https://nuxtjs.org/faq/google-analytics
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
@cawa-93 use context https://nuxtjs.org/api/context and
routeobject like this:you can look here too: https://nuxtjs.org/faq/google-analytics