I've just switched to the new Google Analytics Universal Analytics platform, using the new javascript API - Analytics.js
我刚刚使用新的JavaScript API - Analytics.js切换到新的Google AnalyticsUniversal Analytics平台
In the first example code snippet from the docs a tracking object is created, then a pageview of the current page is logged using that tracking object.
在创建跟踪对象的文档的第一个示例代码段中,使用该跟踪对象记录当前页面的页面浏览量。
ga('create', 'UA-XXXX-Y', 'auto');
ga('send', 'pageview');
Notice the 'auto'
argument - I can't work out what that's there for.
请注意'auto'参数 - 我无法弄清楚它的用途。
I had a look at the method reference and it seems that the relevant parameter is optional and should contain configuration key/value pairs. Examples can be found in the field reference. If the parameter is optional it seems odd to pass 'auto'
here unless it does something of significance, so you have to assume it does, but I can't find any mention of this.
我查看了方法引用,似乎相关参数是可选的,应该包含配置键/值对。例子可以在现场参考中找到。如果参数是可选的,那么在这里传递'auto'似乎很奇怪,除非它有意义,所以你必须假设它,但我找不到任何提及。
Also, in the auto generated code in your account it does a similar thing but passes your domain
此外,在您帐户中的自动生成代码中,它会执行类似的操作但会通过您的域
ga('create', 'UA-XXXX-Y', 'mydomain.com');
The fact your domain is specifically passed when they have it available again suggests it does something meaningful - otherwise they'd probably just use 'auto'
here too. But again, there's no mention of why this is done.
当你的域名再次可用时,你的域名被特别传递,这表明它确实有意义 - 否则他们可能只是在这里使用'auto'。但同样,没有提到为什么这样做。
Am I missing something really obvious?
我错过了一些非常明显的东西吗
2 个解决方案
#1
9
Actually when I look in to code it does not pass the name of my property but the standard domain set in the configuration - which makes a lot more sense, since the parameter sets the cookie domain (in case of "auto"
to the value of to the hostname without subdomains). Alternatively you can pass a configuration object as third parameter (which might contain a cookie domain setting). Try and set a wrong parameter - you'll get a "no storage" error in the analytics debugger since the code cannot set a cookie.window.location.hostname
实际上,当我查看代码时,它没有传递我的属性的名称,而是在配置中设置标准域 - 这更有意义,因为参数设置了cookie域(如果是“auto”,则为window.location.hostname到没有子域的主机名)。或者,您可以将配置对象作为第三个参数传递(可能包含cookie域设置)。尝试并设置错误的参数 - 您将在分析调试器中收到“无存储”错误,因为代码无法设置cookie。
#2
3
If your concern is only with tracking across subdomains (ex: www.example.com, site1.example.com, site2.example.com), then it's already taken care of with this auto
option in universal analytics.
如果您只关注子域名之间的跟踪(例如:www.example.com,site1.example.com,site2.example.com),那么它已经在通用分析中使用此自动选项进行处理。
Per the 'Automatic Cookie Domain Configuration' section in this devguide
根据本偏离中的“自动Cookie域配置”部分
Automatic Cookie Domain Configuration simplifies cross domain tracking implementations by automatically writing cookies to the highest level domain possible when the auto parameter is used. When used on the domain www.example.co.uk, it will try to write cookies in the following order:
自动Cookie域配置通过在使用auto参数时自动将cookie写入*域来简化跨域跟踪实现。在域www.example.co.uk上使用时,它将尝试按以下顺序编写cookie:
- co.uk
- co.uk
- example.co.uk
- example.co.uk
- www.example.co.uk
- www.example.co.uk
Analytics.js will fail to write a cookie on co.uk but will succeed on example.co.uk. Since a cookie was succesfully written on a higher level domain, www.example.co.uk will be skipped.
Analytics.js将无法在co.uk上写一个cookie,但会在example.co.uk上成功。由于cookie已成功写入更高级别的域名,因此将跳过www.example.co.uk。
#1
9
Actually when I look in to code it does not pass the name of my property but the standard domain set in the configuration - which makes a lot more sense, since the parameter sets the cookie domain (in case of "auto"
to the value of to the hostname without subdomains). Alternatively you can pass a configuration object as third parameter (which might contain a cookie domain setting). Try and set a wrong parameter - you'll get a "no storage" error in the analytics debugger since the code cannot set a cookie.window.location.hostname
实际上,当我查看代码时,它没有传递我的属性的名称,而是在配置中设置标准域 - 这更有意义,因为参数设置了cookie域(如果是“auto”,则为window.location.hostname到没有子域的主机名)。或者,您可以将配置对象作为第三个参数传递(可能包含cookie域设置)。尝试并设置错误的参数 - 您将在分析调试器中收到“无存储”错误,因为代码无法设置cookie。
#2
3
If your concern is only with tracking across subdomains (ex: www.example.com, site1.example.com, site2.example.com), then it's already taken care of with this auto
option in universal analytics.
如果您只关注子域名之间的跟踪(例如:www.example.com,site1.example.com,site2.example.com),那么它已经在通用分析中使用此自动选项进行处理。
Per the 'Automatic Cookie Domain Configuration' section in this devguide
根据本偏离中的“自动Cookie域配置”部分
Automatic Cookie Domain Configuration simplifies cross domain tracking implementations by automatically writing cookies to the highest level domain possible when the auto parameter is used. When used on the domain www.example.co.uk, it will try to write cookies in the following order:
自动Cookie域配置通过在使用auto参数时自动将cookie写入*域来简化跨域跟踪实现。在域www.example.co.uk上使用时,它将尝试按以下顺序编写cookie:
- co.uk
- co.uk
- example.co.uk
- example.co.uk
- www.example.co.uk
- www.example.co.uk
Analytics.js will fail to write a cookie on co.uk but will succeed on example.co.uk. Since a cookie was succesfully written on a higher level domain, www.example.co.uk will be skipped.
Analytics.js将无法在co.uk上写一个cookie,但会在example.co.uk上成功。由于cookie已成功写入更高级别的域名,因此将跳过www.example.co.uk。