如何从URL中删除_ga查询字符串 [英] How to remove _ga query string from URL
问题描述
我有一个有GA跟踪的多域网站。最近我们转向了Universal Analytics,并注意到无论何时域名被更改(从美国到韩国/日本),URL都会附加一个_ga = [随机数字]
即from
abc.com
when我点击了日本的网站,URL变成了
japanese.abc.com /?_ ga = 1.3892897.20937502.9237834
- 为什么发生这种情况?
- 如何删除URL的_ga部分
感谢您的帮助。
这是跨域跟踪所必需的(即跟踪跨域限制的人作为一个访问者,而不是每个域的一个访问者)。如果你想跨域跟踪,你不能删除它。 _ga - 部分是标识会话的客户端ID,由于它不能通过cookie(域特定)共享,所以当域更改时,它必须通过url传递。
由于有人将您的网站设置为进行跨域跟踪,我想您确实需要这样做(默认情况下不会发生这种情况)。此参数是Universal Analytics跨域跟踪的必要副作用。如果您确实希望在跟踪代码中查看任何
更新为回复评论中的问题。
-
是否无法删除_ga字符串并仍然具有交叉
域设施?
不,目前没有。浏览器供应商正在研究交叉
域通信的更好方法,所以未来可能会有某些东西,但是参数是最好的方法时,
。
-
另外,如果某个用户随机更改_ga值并按下
,会怎么样? GA如何记录它?
如果用户恰好创建了一个已在
之前使用的客户端ID( 他不会)将他的访问归因于另一个用户。
实际上,Google Analytics只会将其记录为新用户。 b >
对于喜欢玩的人,我做了一个不带_ga参数的跨域跟踪概念证明。这些方面可能会进一步发展,因为它不适合用于生产。
I have a multidomain website for which there is GA tracking. Recently we moved to Universal Analytics and noticed that whenever the domain is changed (from US to Korean/Japanese), a _ga=[random number] is appended to the URL
i.e. from
abc.com
when i click on the japanese site, the URL becomes
japanese.abc.com/?_ga=1.3892897.20937502.9237834
- Why does this happen?
- How can I remove the _ga part of the URL?
Appreciate your help.
解决方案This is needed for cross-domain-tracking (i.e. track people who cross domain boundaries as one visitor and not as one visitor per domain). If you want cross domain tracking you cannot remove this. The _ga - part is the client id which identifies a session and since it cannot be shared via cookies (which are domain specific) it has to be passed via the url when the domain changes.
Since somebody set your site up for cross domain tracking I guess you actually want this (it does not happen by default). The parameter is a necessary side effect of cross domain tracking with Universal Analytics. If you do want this look in the tracking code for any of the linker functions mentioned in the documentation and remove them.
Updated to answer the questions from the comment.
Is there no way to remove the _ga string and still have the cross domain facility?
No, currently not. Browser vendors work on better ways of cross domain communication so there might be something in the future, but at the moment the parameter is the best way.
Also, what if some user randomly changes the _ga value and presses enter? How will GA record that?
If the user happens to create a client id that has been used before (highly unlikely) his visit would be attributed to another user. Realistically Google Analytics will just record him as a new user.
Updated
For those who like to play I did a proof of concept for cross domain tracking without the _ga parameter. Something along those lines could be developed further, as-is it is not suitable for production use.
Update: David Vallejo has a Javascript solution where the _ga parameter is removed via the history API (so while it is still added it is for all intents and purposes invisible to the end user). This is a more elaborate version of Michael Hampton's answer below.
这篇关于如何从URL中删除_ga查询字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!