我使用google标记管理器和google分析插件vue-gtm。
我在同一个容器下在google管理器中创建了3个环境。
作为用户定义的变量,我从环境中创建了名为GA的look up table,并在那里设置了{{ Environment Name}}输入变量。输出变量类似于:
以下是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和所有这些,这样它就可以自动解决这个问题了。有什么想法吗?
发布于 2020-12-28 22:05:00
如果您想调试特定的env -您需要精确地预览这个env (即"dev")
GTM ->管理->环境-> "dev“-> Actions -> -> Link ->输入目标URL ->复制生成的预览链接->转到生成的链接->现在您将在变量中看到"dev”
注意:您已经配置了这个env的目标URL -站点(添加了auth、预览和cookie查询参数)。也可以是本地主机
https://stackoverflow.com/questions/63275404
复制相似问题