[英]Vue-gtag Vue with Google Analytics Not working
Hello I am trying to get my Vue app to register to Google Analytics.您好,我正在尝试让我的 Vue 应用注册到 Google Analytics。 I am using this plugin:我正在使用这个插件:
https://matteo-gabriele.gitbook.io/vue-gtag/v/next/ in a vue 3.0 app with composition API https://matteo-gabriele.gitbook.io/vue-gtag/v/next/在具有组合 API 的 vue 3.0 应用程序中
I have main.js setup this way我以这种方式设置了 main.js
import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import VueGtag from "vue-gtag-next";
const app = createApp(App);
app.use(router)
app.use(VueGtag, {
property: {
id: "xxxmypropertyidxxx"
}
});
app.mount('#app')
and i have my router.js setup this way我以这种方式设置了我的 router.js
import { createRouter, createWebHistory } from 'vue-router'
import { trackRouter } from "vue-gtag-next";
import Home from '../views/Home.vue'
import About from '../views/About.vue'
const routes = [
{
path: '/',
name: 'Home',
component: Home
},
{
path: '/about',
name: 'About',
component: About
}
]
const router = createRouter({
history: createWebHistory(process.env.BASE_URL),
routes,
linkActiveClass: "active", // active class for non-exact links.
linkExactActiveClass: "active" // active class for *exact* links.
})
trackRouter(router);
export default router
Unfortunately, no views are showing up in GA real time.不幸的是,GA 中没有实时显示任何视图。 Even tried adding page view events to individual pages甚至尝试将页面浏览事件添加到各个页面
Thanks for your help!!谢谢你的帮助!!
I had the exact same issue, and it turned out that vue-gtag takes longer to start working than the alternative of embedding the gtag in your HTML header .我遇到了完全相同的问题,事实证明 vue-gtag 开始工作的时间比将 gtag 嵌入 HTML header的替代方法要长。
The "Check your tag setup" support.google page gives you the expectation that Real-Time reports should already be working, but it actually takes much more time for even the Real-Time data to show on the Google Analytics page. “检查您的代码设置”support.google页面让您期望实时报告应该已经开始工作,但实际上即使是实时数据也需要更多时间才能显示在 Google Analytics 页面上。 In my case, it starting working after 18ish hours.就我而言,它在 18 小时后开始工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.