vue-gtag @legacy查询不返回客户端ID
当我使用vue2时,我将Vue-gtag@legacy命名,因为它与Vuejs版本兼容的版本。
插件设置:
import VueGtagPlugin from "vue-gtag";
Vue.use(VueGtagPlugin, {
config: { id: "G-MY-MEASUREMEND-ID" }
});
插件已正确加载 - 这是console.log。
{query: ƒ, config: ƒ, optOut: ƒ, optIn: ƒ, pageview: ƒ, …}
config: ƒ ()
customMap: ƒ (map)
event: ƒ (name)
exception: ƒ ()
linker: ƒ (params)
optIn: ƒ ()
optOut: ƒ ()
pageview: ƒ (param)
purchase: ƒ (params)
query: ƒ ()
refund: ƒ ()
screenview: ƒ (param)
set: ƒ ()
time: ƒ (params)
main.ts 甚至进入回调:
this.$gtag.query("get", "G-MY-MEASUREMEND-ID", "client_id", clientID => {
console.log("CID", clientID);
});
有什么想法吗?
As I'm using Vue2, I insalled vue-gtag@legacy as it's the version compatible with version 2 of VueJS.
main.ts plugin setup:
import VueGtagPlugin from "vue-gtag";
Vue.use(VueGtagPlugin, {
config: { id: "G-MY-MEASUREMEND-ID" }
});
The plugin is loaded correctly - this is the console.log of this.$gtag:
{query: ƒ, config: ƒ, optOut: ƒ, optIn: ƒ, pageview: ƒ, …}
config: ƒ ()
customMap: ƒ (map)
event: ƒ (name)
exception: ƒ ()
linker: ƒ (params)
optIn: ƒ ()
optOut: ƒ ()
pageview: ƒ (param)
purchase: ƒ (params)
query: ƒ ()
refund: ƒ ()
screenview: ƒ (param)
set: ƒ ()
time: ƒ (params)
However if I try to access client_id (which is my main goal), the callback prints nothing - it seems it doesn't even go inside the callback:
this.$gtag.query("get", "G-MY-MEASUREMEND-ID", "client_id", clientID => {
console.log("CID", clientID);
});
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试在nuxt.config.ts 中输入此内容
来源: https:///www.carlcassar。 com/com/act-google-analytics-to-a-nuxt-js-app
try entering this in nuxt.config.ts
source : https://www.carlcassar.com/articles/add-google-analytics-to-a-nuxt-js-app
我不确定是否可以在
vue-gtag
中使用get
方法;我认为查询
方法没有为此做好准备:https://github.com/matteogabriele/vue-gtag/vue-gtag/issues/251
I'm not sure if it's possible to use the
get
method invue-gtag
; I thinkquery
method is not prepared for that:https://github.com/MatteoGabriele/vue-gtag/issues/251