_SetDomainName analytics no longer works

It suddenly stopped working. We have Google Analytics on our page, and a couple of months ago we changed the code so that Google cookies were set only for www.igre123.com , and not these subdomains (we redirect from igre123.com to www.igre123.com, so users always use www.). We did this because we have two subdomains that serve static content (css, js, thumbnails, etc.) from (s.igre123.com and static.igre123com).

To prevent the use of cookies for subdomains (and only for www.), We changed our GA code to look something like this:

... _gaq.push(['_setDomainName','www.igre123.com']); _gaq.push(['_trackPageview']); ... 

This did the trick, but now it no longer works. Does anyone have an idea why this has stopped working? Unfortunately, I do not know exactly when this stopped working: /

edit: tracking otherwise works without problems.

+4
source share
1 answer

OK, after long head bangs, I managed to solve this mystery. It turns out that the order is _gaq.push([]); has the meaning. If you have, besides the usual _setAccount and _trackPageView , any other GA calls (e.g. _setCustomVar ) that set cookies, you must tell GA which domain should set cookies first. It seems obvious in retrospect, but frankly, this is not entirely clear from the documentation.

Anyway, be sure to first place the call to _setDomainName , and then any other GA calls that you may have.

+4
source

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


All Articles