将Google Analytics添加到Laravel / Inertia / Vue应用程序

baubqpgj  于 2023-08-07  发布在  Vue.js
关注(0)|答案(1)|浏览(189)

我正在使用Laravel与Inerta和Vue,我想知道如何将Google Analytics添加到所有页面?
这是我的main.js代码:

/* eslint-disable import/order */
import '@/@iconify/icons-bundle'
import layoutsPlugin from '@/plugins/layouts'
import vuetify from '@/plugins/vuetify'
import VueToast from 'vue-toast-notification'
import 'vue-toast-notification/dist/theme-default.css'
import { createInertiaApp, Link } from '@inertiajs/vue3'
import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers'
import { loadFonts } from '@/plugins/webfontloader'
import './../styles/@core/template/index.scss'
import '@styles/styles.scss'
import { createPinia } from 'pinia'
import { createApp } from 'vue'
import { ZiggyVue } from '../../vendor/tightenco/ziggy/dist/vue.m'
import 'sweetalert2/dist/sweetalert2.min.css'

loadFonts()
createInertiaApp({
    title: title => `${title}`,
    resolve: name => resolvePageComponent(`./pages/${name}.vue`, import.meta.glob('./pages/**/*.vue')),
    setup({ el, App, props, plugin }) {
        // eslint-disable-next-line vue/component-api-style
        const vueApp = createApp({ render: () => h(App, props) })

        vueApp.use(plugin)
            .use(ZiggyVue, Ziggy)
            .use(VueToast, {
                position: 'top',
                pauseOnHover: true,
            }).provide('toast', vueApp.config.globalProperties.$toast)
            .use(vuetify)
            .use(createPinia())
            .use(layoutsPlugin)
            .use(Link)
            .mount(el)

        return vueApp
    },
    progress: {
        color: '#4B5563',
    },
})

字符串

n3h0vuf2

n3h0vuf21#

你必须粘贴谷歌标签的代码片段在您的所有网页的部分。GA文档

相关问题