Google Analytics cookies vs subdomain for static content

后端 未结 3 1844
礼貌的吻别
礼貌的吻别 2021-01-02 05:10

I have a website on www.example.com and use Google Analytics. I\'ve also set up static.example.com which serves all static content.

The problem is that the default b

3条回答
  •  孤城傲影
    2021-01-02 05:41

    Google Analytics stores all session data in cookies that helps it to ‘remember’ previous page views. The function call pageTracker._setDomainName(".example.com") tells every sites to store cookies for host example.com (instead of their own subdomain) to ensure the ability to reach each other's data.

    The form pageTracker._setDomainName("none") is needed in and only in that case when your site spans across multiple, different domain names.

    Set this method to none in the following two situations:

    * You want to disable tracking across sub-domains.
    * You want to set up tracking across two separate domain names.
    

    Cross-domain tracking requires configuration of the _setAllowLinker() and _link methods.

    To answer your question, Google Analytics uses first-party based cookies for collecting data. When you want your static content's traffic to appear in GA, you have to allow cookies for them, too. To avoid this issue, you may choose a server solution like Urchin that parses server log files instead of dealing with cookies.

提交回复
热议问题