Analytics
2K members online now
2K members online now
Dive into multiple domain (Cross/Sub) tracking, implementing Ecommerce and Enhanced Ecommerce, setting up Event tracking, and Universal Analytics code.
 
Guide Me
star_border
Reply

How to set analytics cookie without subdomains (without dot before domain)?

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hi,

 

we want to serve static content from cookieless domain "static.domain.com" for the visitors of "domain.com"

 

By default Analytics set cookies to ".domain.com" what makes "static.domain.com"  not cookieless (browser does send cookies to static.domain.com)

 

Putting ga('create', 'UA-xxx', 'domain.com') doesn't change the point, cookie is still set to ".domain.com"

 

We don't want to use separate domain name for static, and we don't want to use "www.domain.com" for visitors.  

 

Is there a way to tell Analytics set cookies exactly for "domain.com", without a dot ?

 

Thanks.

1 Expert replyverified_user
1 ACCEPTED SOLUTION

Accepted Solutions
Marked as Best Answer.
Solution
Accepted by topic author Alexander G
June 2016

Re: How to set analytics cookie without subdomains (without dot before domain)?

Top Contributor
# 2
Top Contributor

Hi Alexander :-)
I haven't had a chance to test this however have you tried with setting the domain name to 'none'
eg ga('create', 'UA-XXXXX-Y', 'none');
Note- Make sure to clear your cookies and cache after the editing the tracking code, prior to retesting it.

Bronwyn Vourtis, Google Analytics Top Contributor
Was my response helpful? If yes, please mark it as the ‘Best Answer.’ Learn how here

View solution in original post

Marked as Best Answer.
Solution
Accepted by topic author Alexander G
June 2016

Re: How to set analytics cookie without subdomains (without dot before domain)?

Top Contributor
# 2
Top Contributor

Hi Alexander :-)
I haven't had a chance to test this however have you tried with setting the domain name to 'none'
eg ga('create', 'UA-XXXXX-Y', 'none');
Note- Make sure to clear your cookies and cache after the editing the tracking code, prior to retesting it.

Bronwyn Vourtis, Google Analytics Top Contributor
Was my response helpful? If yes, please mark it as the ‘Best Answer.’ Learn how here

Re: How to set analytics cookie without subdomains (without dot before domain)?

Top Contributor
# 3
Top Contributor
Also as an afterthought too.. depending on your setup, while cookies are the preferred method,
you could also look into possibly use local storage
https://developers.google.com/analytics/devguides/collection/analyticsjs/cookies-user-id#disabling_c...
Bronwyn Vourtis, Google Analytics Top Contributor
Was my response helpful? If yes, please mark it as the ‘Best Answer.’ Learn how here

Re: How to set analytics cookie without subdomains (without dot before domain)?

Visitor ✭ ✭ ✭
# 4
Visitor ✭ ✭ ✭
Hey Bronwyn,

ga('create', 'UA-XXXXX-Y', 'none') puts cookie to "domain.com" as wanted, works!

Thanks for this hack (bug?), hope this won't break user tracking - guess this is not fully supported functionality -).

Alexander.