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

坚强是说给别人听的谎言 提交于 2019-12-03 05:49:25

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 window.location.hostname 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.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!