AdWords is now Google Ads. Our new name reflects the full range of advertising options we offer across Search, Display, YouTube, and more. Learn more

2.2K members online now
2.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

Purposes of legacyCookieDomain field

Follower ✭ ☆ ☆
# 1
Follower ✭ ☆ ☆

Dear all,


Could someone explain me what is the purpose of legacyCookieDomain field in analytics.js tracking?

In which case we have to use it?


Thank you for your help.

1 Expert replyverified_user

Re: Purposes of legacyCookieDomain field

Top Contributor
# 2
Top Contributor

Hello :-)
Its for customizing the Cookie Migration when upgrading a site from Classic ga.js tracking to Universal analytics.js tracking code snippet.

When a site is upgraded from ga.js to analytics.js, analytics.js by default, automatically imports the cookies previously created by the ga.js tracking.


Customizing analytics.js history import


To customize how analytics.js selects a cookie value when there are multiple sets of classic Google Analytics cookies, you can use the legacyCookieDomain field.


The value provided to this field should match the value your classic Google Analytics tracker had used for the _setDomainName command.

ga('create', 'UA-XXXX-Y', 'auto', {'legacyCookieDomain': ''});



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

Re: Purposes of legacyCookieDomain field

Follower ✭ ☆ ☆
# 3
Follower ✭ ☆ ☆
Thank you for your fast answer Bronwyn Smiley Happy
Do you know if leagacyCookieDomain will be used each time the visitor accesses to the website or just the first time and will not work if the analytics.js visitor cookie is present for the cookieDomain ?

On my website, I've got 2 applications :
- : using ga.js for the moment and storing cookies on
- : using analytics.js and storing also cookies on

quotation can be accessible only through www and I wish to persist the visitor and the related real traffic source.
I can't easily change (as example adding a linker).
So, in my case, legacyCookieDomain field on quotation app should be a valid solution ?