Google Analytics(分析)统计我所有子域的访问次数,但将我的子域列为引荐

发布于 2024-10-11 12:17:00 字数 493 浏览 10 评论 0原文

我有一个网站,其中包含 mydomain.com(以及从中派生的 URL,例如 mydomain.com/the/rest/)和一些子域,例如 first.mydomain.com 和 secondary.mydomain.com。现在,我在网站的所有页面中使用相同的 Analytics 代码片段。

问题是 Google Analytics(分析)向我显示 mydomain.com 和 .mydomain.com 作为引荐,但似乎所有访问都被计算在内。

所以我想我有两个选择,但我都不知道如何实现:

  1. 让 Analytics 了解 mydomain.com 和所有 .mydomain.com 都是同一网站的一部分,因此它不计算之间的链接将它们视为引荐。

  2. 隔离 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:

  1. 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.

  2. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

如痴如狂 2024-10-18 12:17:01

除非另有说明,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)种解决方案。

  • (最佳)实施跨子域跟踪。基本上,指示 GA您可以使用 _setDomainName 指令来覆盖默认域设置,您需要在对所有域和子域进行 _trackPageview 调用之前声明该指令。这将解决跨域跟踪问题,

如下所示:

_gaq.push(['_setDomainName', 'foo.com']);

其他不太理想但可行的替代方案:

  • 您可以为他们提供完全不同的跟踪代码,即使用不同的帐户跟踪 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 about co.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.

  • (Best) Implement cross-subdomain tracking. Basically, instruct GA to override the default domain settings. You do this with the _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:

_gaq.push(['_setDomainName', 'foo.com']);

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.

无人接听 2024-10-18 12:17:01

在 GA 内的 Admin > 下跟踪代码,我建议仔细检查 Google 为您生成的代码。在标准选项卡下,当我选择具有多个子域的一个域时,Google生成了以下内容:

_gaq.push(['_setDomainName', 'foo.com']);

我必须进入“自定义”选项卡并将该行修改为如下所示:

_gaq.push(['_setDomainName', '.foo.com']);

Within GA under Admin > Tracking Code, I recommend double-checking the code Google generates for you. Under the Standard tab, when I chose One domain with multiple subdomains, Google generated this:

_gaq.push(['_setDomainName', 'foo.com']);

I had to go under the Custom tab and modify the line to look like this:

_gaq.push(['_setDomainName', '.foo.com']);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文