Google Analytics and the static subdomain

First of all: this is not the same as being similar, but without the www prefix problem .

I have an example.com site (again, there is no ā€œwww.ā€ Prefix). I would like to use static content from the static.example.com subdomain, but Google Analytics continues to send cookies from the static subdomain.

I used a simple CNAME to create a subdomain, and here is the Google Analytics snippet code:

<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-XXX-XX']);       
  _gaq.push(['_setDomainName', 'none']); 
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>

I tried installing _setDomainNameon example.comand noneas above, but it does not work. I also created a new static subdomain (static2.example.com, etc.) every time, but it also did not work.

Thanks in advance.

+3
1

cookie GA, GA, cookie . www DomainName, . , cookie example.com(no www) cookie , .

:

  • . (www - ) _setDomainName

  • . - staticexample.com

+1

Source: https://habr.com/ru/post/1774397/


All Articles