javascript - 当定向到移动网站时,谷歌分析会丢失引荐来源网址的跟踪

标签 javascript redirect mobile google-analytics

我有一个网站 www.xxxxx.com,如果访问者使用移动设备,该网站会将访问者引导至 www.xxxxx.com/mobile。我使用 JavaScript 代码来检测它们是否在移动设备上并将它们定向到移动子文件夹。代码如下:

<script type="text/javascript">
 <!--
 if (screen.width <= 679) {
   window.location = "http://www.xxxxx.com/mobile/";
}
//-->
</script>

一切都运行良好,但问题是,如果访问者被定向到移动设备,谷歌分析不会保留主网站的原始引荐来源网址。例如,如果客户搜索 X 公司并通过手机访问我们的 www.xxxxx.com,并且他们被定向至 www.xxxxx.co/mobile,则 Google 分析会将此访问者显示为“直接访问者”,而不是显示“推荐人”网站”或搜索的关键字。

如何查看原始推荐人和搜索到的关键词? 提前谢谢了。

最佳答案

查看有关 Causes for self-referrals > Redirects and Self-referrals 的 Google 文档:

meta refresh and javascript based redirects

Non server-side invoked redirects such as the meta refresh html tag or javascript window.location methods may hide or obscure referrer information from Google Analytics, therefore we don’t recommend using such methods on any page that is likely to be a landing page.

关于javascript - 当定向到移动网站时,谷歌分析会丢失引荐来源网址的跟踪,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24695365/

相关文章:

javascript - 自动扫描并聚焦 HTML 页面的元素

javascript - 模块构建失败 : Error: Couldn't find preset "transform-class-properties" relative to directory

javascript - 如何在 div 加载内容时发出警报

css - 移动设计更改页脚

css - 响应式网页设计 - 使用 px 值

javascript - 使用 JWT 身份验证进行 WordPress Rest API 并获取 [jwt_auth] ip_blocked”

javascript - 使用 javascript 重写表单 url

iis-7 - 在 IIS7 中重定向到 www - 经典管道模式

redirect - Playframework:将条目路由到外部 URL

javascript - Backbone.js + jsOAuth