我的SPA应用程序和分析出现了一个奇怪的问题。某些用户在会话期间丢失了源/媒体参数。
我正在使用Google Tag Manager推荐使用的历史API,并且它工作正常。但对于大约30%的用户来说,他们的utm参数丢失了,成为了推荐人。我不明白这种行为,有人见过这种行为吗?
所以,我知道100%是
(source/medium) = mySource / affiliate但在分析中,大约30%的人失去了他们的utm参数,这就变成了:
(source/medium) = mySource / affiliate (70%)
(source/medium) = mysource.com / referral (30%)有什么建议吗?我现在有点迷路了。
发布于 2019-04-28 21:56:56
由于这些站点是单页面应用程序(SPA),您很可能会面临“无管理推荐”的问题。
如果是这种情况,则会发生的情况是,您覆盖了分析命中中的location字段,丢失了原始的UTM参数,而引用仍然随命中一起发送,因此分析将第二次命中识别为新的流量来源。解决方案之一是存储原始页面URL并将其作为location发送,同时在page字段中发送实际访问的URL。
Simo Ahava在这个主题上提供了一个非常好的article,并提供了进一步的技巧,可以为您提供帮助。
发布于 2021-05-07 22:39:20
这个关于“流氓推荐”问题的article暴露了一个只适用于谷歌标签管理器的解决方案,而且如果你遵循这篇文章,你将为整个应用程序发送相同的页面位置(如果我理解正确的话),这是我们不想要的。
此外,它没有考虑到对参数的一些过滤(只有在存在有用的参数时才发送参数),所以我们提出了这个解决方案。
请注意,代码需要在页面的第一次加载和每次路由更改时运行。
函数来检索参数。
// return the whole parameters only if at least one of the desired parameters exists
const retrieveParams = () => {
let storedParams;
if ('URLSearchParams' in window) {
// Browser supports URLSearchParams
const url = new URL(window.location.href);
const params = new URLSearchParams(url.search);
const requestedParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_content', 'gclid'];
const hasRequestedParams = requestedParams.some((param) => {
// true if it exists
return !!params.get(param);
});
if (hasRequestedParams) {
storedParams = params;
}
}
return storedParams;
}创建完整的URL
// look at existing parameters (from previous page navigations) or retrieve new ones
const storedParams = window.storedParams || retrieveParams();
let storedParamsUrl;
if (storedParams) {
// update window value
window.storedParams = storedParams;
// create the url
const urlWithoutParams = document.location.protocol + '//' + document.location.hostname + document.location.pathname;
storedParamsUrl = `${urlWithoutParams}?${storedParams}`;
}将值发送到分析(使用gtag)
// gtag
gtag('config', 'YOUR_GA_ID', {
// ... other parameters
page_location: storedParamsUrl ?? window.location.href
});或
gtag('event', 'page_view', {
// ... other parameters
page_location: storedParamsUrl ?? window.location.href,
send_to: 'YOUR_GA_ID'
})发布于 2021-06-11 22:03:12
答案是(很可能) referrer。当用户访问一个站点(在url中有utm)时,它会有推荐人,例如点击站点时的xyz.com。SPA不会重新加载页面,这意味着推荐人仍然是xyz.com,但url现在不包括utm
因此,对于谷歌来说,这样的第二次页面浏览是一个新的会话。要解决这个问题,你需要在第一个页面上的referrer上工作--视图(实际页面加载)将提供正确的referrer,而在所有其他点击中,它将提供null或domain作为referrer :)
https://stackoverflow.com/questions/55848962
复制相似问题