-
Notifications
You must be signed in to change notification settings - Fork 12.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add 'auto' to the Google Analytics tracker create method. #1562
Conversation
@@ -159,7 +159,7 @@ parameter](https://developers.google.com/analytics/devguides/collection/analytic | |||
before sending any events/pagviews. In use it looks like this: | |||
|
|||
```js | |||
ga('create','UA-XXXXX-X'); | |||
ga('create','UA-XXXXX-X','auto'); |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
Cc: @mathiasbynens |
@alrra I can, but it wasn't there before and the space wasn't in any of the other code in the snippet. |
@philipwalton The code examples in the docs aren't quite consistent at the moment, so might as well fix that. Thanks! |
@alrra Sure, no problem. Updated. |
@@ -33,7 +33,7 @@ | |||
e=o.createElement(i);r=o.getElementsByTagName(i)[0]; | |||
e.src='//www.google-analytics.com/analytics.js'; | |||
r.parentNode.insertBefore(e,r)}(window,document,'script','ga')); | |||
ga('create','UA-XXXXX-X');ga('send','pageview'); | |||
ga('create', 'UA-XXXXX-X', 'auto'); ga('send', 'pageview'); |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
@philipwalton thanks!
I'm for this addition. :) |
Sorry, yeah I thought that was weird. Updated and squashed to make it easier to compare. |
Update spacing to be consistent.
Thank you for being so responsive! 💜 |
The Google Universal Analytics now supports automatic cookie domain configuration simply by adding `auto` to the analytics tracker create method: `ga('create', 'UA-XXXX-Y', 'auto');`. From https://developers.google.com/analytics/devguides/collection/analyticsjs/domains#auto: "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: 1. co.uk 2. example.co.uk 3. 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" So, when this parameter is omitted (as it was prior to this commit), Google Universal Analytics will default to using `location.hostname`, which will include the subdomain, preventing websites with multiple subdomains from being able to automatically track unique users across those subdomains. Note: The `auto` parameter is now officially part of the recommended Google Universal Analytics snippet. https://developers.google.com/analytics/devguides/collection/analyticsjs/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Ref: https://developers.google.com/analytics/devguides/collection/analyticsjs/domains#auto Close: #1562.
Merged in 4fca586. Thanks again @philipwalton! |
You're welcome! |
The Google Universal Analytics now supports automatic cookie domain configuration simply by adding `auto` to the analytics tracker create method: `ga('create', 'UA-XXXX-Y', 'auto');`. From https://developers.google.com/analytics/devguides/collection/analyticsjs/domains#auto: "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: 1. co.uk 2. example.co.uk 3. 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" So, when this parameter is omitted (as it was prior to this commit), Google Universal Analytics will default to using `location.hostname`, which will include the subdomain, preventing websites with multiple subdomains from being able to automatically track unique users across those subdomains. Note: The `auto` parameter is now officially part of the recommended Google Universal Analytics snippet. https://developers.google.com/analytics/devguides/collection/analyticsjs/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Ref: https://developers.google.com/analytics/devguides/collection/analyticsjs/domains#auto h5bp/html5-boilerplate#1562
The Google Universal Analytics now supports automatic cookie domain configuration simply by adding `auto` to the analytics tracker create method: `ga('create', 'UA-XXXX-Y', 'auto');`. From https://developers.google.com/analytics/devguides/collection/analyticsjs/domains#auto: "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: 1. co.uk 2. example.co.uk 3. 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" So, when this parameter is omitted (as it was prior to this commit), Google Universal Analytics will default to using `location.hostname`, which will include the subdomain, preventing websites with multiple subdomains from being able to automatically track unique users across those subdomains. Note: The `auto` parameter is now officially part of the recommended Google Universal Analytics snippet. https://developers.google.com/analytics/devguides/collection/analyticsjs/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Ref: https://developers.google.com/analytics/devguides/collection/analyticsjs/domains#auto Close: h5bp/html5-boilerplate#1562.
Google Analytics supports automatic cookie domain configuration, and this is now officially part of the recommended GA code snippet.
When this parameter is omitted (as it was prior to this pull request), Google Analytics will default to using
location.hostname
, which will include the subdomain. This prevents websites with multiple subdomains from being able to automatically track unique users across those subdomains.