Skip to content
This repository has been archived by the owner on Apr 24, 2019. It is now read-only.

Commit

Permalink
Add auto to the GA tracker create method
Browse files Browse the repository at this point in the history
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
  • Loading branch information
alrra committed Jul 19, 2014
1 parent 2ecd083 commit 7b8245e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

### HEAD
* Add `auto` to the Google Universal Analytics tracker create method
* Add `timeline` and `timelineEnd` to the list of `console` methods
* Update to Apache Server Configs v2.6.0
* Update bower and npm dependencies
Expand Down
2 changes: 1 addition & 1 deletion templates/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,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');
</script>
</body>
</html>

0 comments on commit 7b8245e

Please sign in to comment.