Analytics.js: What does 'auto' argument do on tracking object creation?

前端 未结 2 1889
慢半拍i
慢半拍i 2021-02-07 04:38

I\'ve just switched to the new Google Analytics Universal Analytics platform, using the new javascript API - Analytics.js

In the first example code snippet from the doc

2条回答
  •  情话喂你
    2021-02-07 04:44

    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.

    Per the 'Automatic Cookie Domain Configuration' section in this devguide

    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:

    • co.uk
    • 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.

提交回复
热议问题