Cross-Domain Cookies with Google Analytics

When you need to track across multiple domains

Posted by on June 17th, 2016

At work we’ve been trying determine how much audience overlap we have between two of our main websites. We’ve migrated to Google Analytics Premium this year and are creating a “roll-up” property where all analytics from all of our properties gets rolled into one.

After enabling the roll-up, we tried to run reports on how many users visited both sites, but came back with 0 users. After doing some research we discovered Google Analytics by default will use first-party cookies to identify users. However, first-party cookies are not accessible (without crazy work arounds) across domains.

It is more resonable to “write” cookies to multiple domains with some resonable solutions. With Google Analytics Premium, however, it is completely possible to have GA do all the heavy lifting for you.

The solution is use Google Analytic’s auto linker to support Cross-Domain cookies. This will allow GA to smartly link user’s across both domains. The setting must be set on all tags for each site. Example config:

ga('create', 'UA-XXXXXXX-Y', 'auto', {'allowLinker': true});
ga('require', 'linker');
ga('linker:autoLink', [''] );

Hopefully this will provide useful for someone.


Justin is a Sr. Director of Engineering at Deseret Digital Media, Previous President of the Utah PHP Usergroup, and frequently works with the Utah Open Source Foundation which organizes the OpenWest Conference. Justin loves just about anything with web technologies from PHP, JavaScript, Node.js, Salt, and managing engineering teams.

Learn More