【发布时间】:2020-08-06 00:55:43
【问题描述】:
我正在使用谷歌标签管理器和谷歌分析与名为vue-gtm的插件
我在同一个容器下的 google tag manager 中创建了 3 个环境。
作为用户定义的变量,我从环境中创建了名为 GA 的look up table,并在那里设置了输入变量{{ Environment Name}}。输出变量如下:
- 开发 - ua_123_1
- 暂存 - ua_456_1
- 产品 - ua_789_1
这是 vue-gtm 的样子:
Vue.use(VueGtm, {
id: config.services.googleTag.id,
queryParams: config.services.googleTag.gtm_auth ? { // Add url query string when load gtm.js with GTM ID (optional)
gtm_auth: config.services.googleTag.gtm_auth,
gtm_preview: config.services.googleTag.gtm_preview,
gtm_cookies_win: config.services.googleTag.gtm_cookies_win,
} : {},
defer: false, // defaults to false. Script can be set to `defer` to increase page-load-time at the cost of less accurate results (in case visitor leaves before script is loaded, which is unlikely but possible)
enabled: true, // defaults to true. Plugin can be disabled by setting this to false for Ex: enabled: !!GDPR_Cookie (optional)
debug: true, // Whether or not display console logs debugs (optional)
vueRouter: router, // Pass the router instance to automatically sync with router (optional)
});
进入站点后,在分析中没有任何反应,因为在调试中,我仍然可以看到环境名称变量设置为:'Preview Environment 2 2020-08-05 071543'。不知道为什么。
我应该是应该从代码中设置这个的人吗?我不这么认为,因为我正在使用gtm_preview 和所有这些,以便它可以自动解决这个问题。有什么想法吗?
【问题讨论】:
标签: javascript vue.js google-tag-manager