用于静态内容的 Google Analytics cookie 与子域 [英] Google Analytics cookies vs subdomain for static content

查看:23
本文介绍了用于静态内容的 Google Analytics cookie 与子域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 www.example.com 上有一个网站并使用 Google Analytics.我还设置了 static.example.com 来提供所有静态内容.

I have a website on www.example.com and use Google Analytics. I've also set up static.example.com which serves all static content.

问题是 GA 的默认行为是在.example.com"上发布 cookie,但我不希望静态内容流量承载 GA cookie 的权重.

The problem is that the default behavior of GA is to issue cookies on ".example.com" but I don't want the static content traffic to be carrying the weight the GA cookies.

我尝试了 pageTracker._setDomainName("none"); 并且它在解决 cookie 问题方面效果很好,但它完全搞砸了平均站点停留时间"报告(从平均 5 分钟开始到 40 分钟,直到我恢复 _setDomainName 调用的那一天).

I tried pageTracker._setDomainName("none"); and it worked well for the cookies problem but it completely messed up the "Avg. Time on Site" report (from 5 mins average it went to 40 mins until the day I reverted the _setDomainName call).

知道为什么会发生这种情况,我该如何解决?

Any idea why this is happening and how could I fix it?

推荐答案

解决方案是做 pageTracker._setDomainName("www.example.com") 然后 GA 将 cookie 发给 ".www.example.com".这样,分析仍然可以正常工作,并且 cookie 不会泄漏到其他静态子域中.

The solution is to do pageTracker._setDomainName("www.example.com") and then GA will issue the cookies to ".www.example.com". That way analytics still works fine and the cookies do not leak into the other static subdomain.

这篇关于用于静态内容的 Google Analytics cookie 与子域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆