Google Analytics(分析)统计我所有子域的访问次数,但将我的子域列为引荐
我有一个网站,其中包含 mydomain.com(以及从中派生的 URL,例如 mydomain.com/the/rest/)和一些子域,例如 first.mydomain.com 和 secondary.mydomain.com。现在,我在网站的所有页面中使用相同的 Analytics 代码片段。
问题是 Google Analytics(分析)向我显示 mydomain.com 和 .mydomain.com 作为引荐,但似乎所有访问都被计算在内。
所以我想我有两个选择,但我都不知道如何实现:
让 Analytics 了解 mydomain.com 和所有 .mydomain.com 都是同一网站的一部分,因此它不计算之间的链接将它们视为引荐。
隔离 mydomain.com 和所有 .mydomain.com,以便我可以分别获取每个域的统计信息。
我怎样才能实现这些选项,您认为哪一个更合适?
谢谢。
I have a site which consists of mydomain.com (and URLs derived from it such as mydomain.com/the/rest/) and some subdomains like first.mydomain.com and second.mydomain.com. Right now, I'm using the same Analytics' snippet of code in all of the site's pages.
The problem is Google Analytics shows me mydomain.com and .mydomain.com as referrals, but it seems the visits are counted for all.
So I guess I have two options, none of them I know how to achieve:
Make Analytics understand that mydomain.com and all the .mydomain.com are all part of the same site, so it doesn't count links between them as referrals.
Isolate mydomain.com and all the .mydomain.com so I can have stats for each of them separately.
How can I achieve each of those options and which one you think is more appropriate?
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
除非另有说明,Google Analytics 会将其 cookie 设置在
document.domain
级别。即,无论出于何种意图和目的,它都认为 www.foo.com 和 sub.foo.com 是完全独立的实体。虽然这看起来很奇怪,但请考虑一下在子域中销售服务的co.uk
域或服务。因此,一旦您登陆 sub.foo.com,在 www.foo.com 上设置的 cookie 将不可见,因为它们没有设置在正确的域中。因此,Google Analytics 表示“这是一次全新的访问!而且它们是从 www.foo.com 引用的
。因此,有 2(或 3)种解决方案。
_setDomainName
指令来覆盖默认域设置,您需要在对所有域和子域进行_trackPageview
调用之前声明该指令。这将解决跨域跟踪问题,如下所示:
其他不太理想但可行的替代方案:
您可以为他们提供完全不同的跟踪代码,即使用不同的帐户跟踪 foo.com 和 sub.foo.com。 /p>
您可以将它们保留在同一帐户上并创建单独的过滤器(在配置文件中按主机名进行过滤) 。这将允许您分离数据,但不会解决您的自我推荐问题。
你最好的选择是#1。它将彻底解决自我推荐问题。
Google Analytics, unless told otherwise, sets its cookies on the
document.domain
level. ie, it thinks that www.foo.com and sub.foo.com are completely separate entities, for all intents and purposes. While this seems odd, think aboutco.uk
domains or services that sell services at the subdomain.As a result, the cookies set on www.foo.com aren't visible once you land on sub.foo.com, because they're not set at the right domain. So, Google Analytics says "this is a brand new visit! And they're being referred from www.foo.com
So, there are 2 (or 3) solutions.
_setDomainName
directive, which you need to declare before your_trackPageview
calls on all domains and subdomains. This will solve the cross domain tracking issue.That looks like this:
Other less ideal but workable alternatives:
You could give them entirely different tracking codes. ie, tracking foo.com and sub.foo.com using different accounts.
You could keep them on the same account and create separate filters (filtering by Hostname, in profile settings, for each). This will allow you to separate the data, but will not solve your self-referral issue.
Your best choice is #1. It will totally resolve the self referral issue.
在 GA 内的
Admin > 下跟踪代码
,我建议仔细检查 Google 为您生成的代码。在标准
选项卡下,当我选择具有多个子域的一个域
时,Google生成了以下内容:我必须进入“自定义”选项卡并将该行修改为如下所示:
Within GA under
Admin > Tracking Code
, I recommend double-checking the code Google generates for you. Under theStandard
tab, when I choseOne domain with multiple subdomains
, Google generated this:I had to go under the Custom tab and modify the line to look like this: