_ga cookie中的值是什么? [英] what are the values in _ga cookie?

查看:984
本文介绍了_ga cookie中的值是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用通用分析。通用分析创建第一方Cookie _ga

I am using universal analytics. universal analytics creates first party cookie _ga

 _ga=1.2.286403989.1366364567;

286403989是clientId

286403989 is clientId

1366364567是时间戳

1366364567 is timestamp

_ga cookie中的 1 2 是什么?

what is 1 and 2 in _ga cookie?

推荐答案

_ga=1.2.286403989.1366364567;

这些是4点分隔的字段。这是我到目前为止可以找到的:

These are 4 dot separated fields. This is what I could figure out so far:

我不确定,这是版本号。如果Cookie格式将来更改。目前固定为1。

I'm not sure but I believe this is a versioning number. In case the cookie format changes in the future. Seems to be fixed at 1 at the moment.

此栏位用于计算

默认情况下,cookie设置在路径 / 并在document.location.hostname(除去www前缀)的域中。

By default cookie are setup at path / and at the domain on document.location.hostname (with the www. prefix removed).

您可以在sub.example.com设置_ga cookie,设置在example.com。因为浏览器上的cookie API的工作原理,所以没有办法判断你使用的是正确的cookie。

You could have a _ga cookie set at sub.example.com and another cookie set at example.com. Because the way the cookie API on browsers works there's no way to tell which is the correct cookie you use.

所以第二个数字是组件的数量(点分隔)

So the second number is the number of components (dot separated) at the domain.


  • 对于sub.example.com,数字将为3

  • .com该数字为2
  • for sub.example.com the number would be 3
  • for example.com the number would be 2

该路径默认为 / 也可以通过将 cookiePath 选项传递到 ga.create 方法来更改它。如果你通过它,这个字段变成2个数字分开。第二个数字是路径中的数字斜线。

The path defaults to / but you can also change it by passing the cookiePath option to the ga.create method. If you pass it this field becomes 2 numbers dash separated. And the second number is the number slashes in the path.

使用这些数字,analytics.js脚本可以正确识别要使用的Cookie,以防有多个Cookie设置。

Using these numbers the analytics.js script can correctly identify the cookie to be used in case there are multiple cookies set.

例如:
假设您有一个网站住在sub1.sub2.example.com/folder1,以防您只想将Cookie存储在您的网站,而不让其他子网域或资料夹显示您可以使用以下配置:

eg: Imagine that you have a site that lives at sub1.sub2.example.com/folder1 in case you want to store the cookie only on your site and not make it visible to other subdomains or folders you can use the following configs:

ga('create', 'UA-XXXX-Y', {
  'cookiePath': '/folder1/',
  'cookieDomain': 'sub1.sub2.example.com'
});

在这种情况下,cookie看起来像这样;

In this case the cookie will look somoething like this;

_ga=1.4-2.XXXXXXXX.YYYYYYY



< h2>第三栏位

这是随机产生的使用者ID。用于识别不同的用户。

3rd Field

This is a random generated user ID. Used to identify different users.

这是Cookie第一次设置的时间戳

It's a timestamp of the first time the cookie was set for that user.

new Date(1366364567*1000)
> Fri Apr 19 2013 06:42:47 GMT-0300 (BRT)

在userId冲突的情况下识别用户。

This is also used to uniquely identify users in case of userId collisions.

值得一提的是,cookie不是一个API。在未来它可能完全改变。 Google不建议直接阅读/写入_ga cookie。您应该通过其中一个跟踪库(如analytics.js)与Google Analytics(分析)进行互动。

Worth mentioning that a cookie is not an API. In the future it may completely change. Google doesn't recommend reading/writing the _ga cookie directly. You should interact with Google Analytics through one of the tracking libraries such as analytics.js. There's not a lot of use for this information other than curiosity.

如果您正在直接阅读/写下这个cookie,那么就是错误。

If you are reading/writing directly the cookie you are doing it wrong.

这篇关于_ga cookie中的值是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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