gpt4 book ai didi

javascript - Google Analytics - 在 JS 中使用parent.location.hash没有效果

转载 作者:行者123 更新时间:2023-12-03 02:35:20 24 4
gpt4 key购买 nike

在我们的网站中,我们使用步骤来完成表单,每个步骤都有自己的“继续”按钮以继续下一步,依此类推,直到用户完成所有步骤。问题是我们使用 parent.location.hash 来处理当前步骤的 url 中的哈希值,同时我们需要在 GA 中进行跟踪。所以基本上这是我们的代码:

switch (hash) {
case 'step_0':
parent.location.hash = 'warning';
ga('send', 'pageview', '/#warning');
break;
case 'step_1':
parent.location.hash = 'categories';
ga('send', 'pageview', '/#categories');
break;
case 'step_2':
parent.location.hash = 'names';
ga('send', 'pageview', '/#names');
break;
case 'step_3':
parent.location.hash = 'city';
ga('send', 'pageview', '/#city');
break;
case 'step_4':
parent.location.hash = 'members';
ga('send', 'pageview', '/#members');
break;
case 'step_5':
parent.location.hash = 'privacy';
ga('send', 'pageview', '/#privacy');
break;
}

很简单,但问题是没有录制任何轨道,所以我错过了什么?有任何想法吗?谢谢。

更新:带有哈希值的网址看起来类似于:https://example.com/#warning

最佳答案

尝试此解决方案 post并执行以下操作:

ga('send', 'pageview', {
'page': parent.location.pathname + parent.location.search + parent.location.hash
});

关于javascript - Google Analytics - 在 JS 中使用parent.location.hash没有效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48553757/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com