I am in the process of investigating the way of moving from a current website to a new beta version, which lives on a different TLD. I am thinking about building a service that transfers a collection of different cookies (mostly tracking, cookie banner, etc) from the old to the new domain.

From what I can find, Google suggests passing the client ID to the new domain and injecting it into ga(), which can be read on https://developers.google.com/analytics/devguides/collection/analyticsjs/cross-domain.

However, because I would like to transfer other cookies anyway, I was wondering if I can just copy the analytics cookies from the old to the new domain. And if i CAN, i'm wondering if i SHOULD, i.e. are there any potential issues this can cause, or things that I should take into consideration with an approach like this.

  • I don't know too much about analytics cookies. But what I have experienced is that if you put the tracking code from your previous domain onto your new site, all of your returning visitors should still be there in your analytics data for future days. GA shouldn't reset them as new visitors.
    – Michael d
    Commented Mar 14, 2018 at 14:54

1 Answer 1


In theory, you could copy the cookies and everything should work the same way. You can make a test and see in real time reports if your session remains the same (make sure you use a specific and unique medium/source). Fast and reliable.

The only thing you should keep in mind is that cookie_domain (in analytics.js or gtag.js) must be set to none in order to allow hits from multiple domains.

Setting an incorrect cookie domain will result in no hits being sent to Google Analytics.

If you are using a previous version of Google Analytics (ga.js), then use setDomainName() function.

By default, the method is set to auto, which attempts to resolve the domain name based on the document.domain property in the DOM. There are three modes to this method: ("auto" | "none" | [domain])

The cookies you should copy (assuming you are using analytis.js) should be:

  • _ga
  • _gid

Best solution

Despite all of that, I would use Google Analytics Linker Plugin to share cookie information among domains in order to have a scalable solution and prevent future changes on the platform.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.