3
votes

We have two domains that serve the exact same SaaS application. Due to legacy 3rd-party integration's we can't discard the old domain or redirect it (i.e. 301). I'm aware this is lousy from an SEO perspective but this app is not publicly available so that's not a concern.

I'm looking for a way track them with Google Analytics as ONE site. I've seen other posters with similar situations but I have one wrinkle that has not been addressed. I also need to be able to track sub-domains. (i.e, partner1.old-domain.com || partner1.new-domain.com)

So the requirements look like this:

Track over-all traffic as one site: (old-domain.com || new-domain.com)

Track all subdomain traffic (profile filters?): (partner1.old-domain.com || partner1.new-domain.com)

Note: Trying to avoid the use of _gaq.push(['_setAllowLinker', true]);. As I understand it, this is not really for true cross-site/cross-domain situations.

2

2 Answers

2
votes

The setup you are describing is a multiple top level domain setup. The issue is the cookie used to persist the Google Analytics session can only be stored at a sub-domain or root domain level, and therefore when you have multiple top level domains you need to pass this session data from one TLD (top level domain) to the other.

First lets look at a simpler example, multiple sub domains. In order to track this scenario:

  • partner1.old-domain.com
  • partner2.old-domain.com

We need to scope the cookie to the root domain, in this case 'old-domain.com', the means tracking can persist across both the partner1 and partner2 sub-domains. This is simply achieved by using the method:

_gaq.push(['_setDomainName', 'example.com']);

However this get more complex when adding your new TLD. When adding that we get this:

  • partner1.old-domain.com
  • partner2.old-domain.com
  • partner1.new-domain.com
  • partner2.new-domain.com

In order for this set up to function we need to use the setDomainName method and the setAllowLinker

 _gaq.push(['_setDomainName', 'example.com']);
 _gaq.push(['_setAllowLinker', true]);

There is the best way of persisting a tracking session across multiple domains. The cookie cannot be read by multiple TLDs, meaning the Analytics cookie set on 'old-domain.com' cannot be read by 'new-domain.com' therefore the Google Analytics visitor session cannot persist.

The way to surmount this issue is to bypass the cookie, and this is how it is done: upon executing a link from 'old-domain.com' to 'new-domain.com' the session information is first passed into the URL and then is parsed by Google Analytics on the second domain allowing the persistence of the visitor session.

Google has provided a method of doing this by way of the '_link()' function. This function needs to be used with all links between domains. This is both from the old domain to the new one and from the new domain to the old one.

<a href="http://partner1.new-domain.com/"
  onclick="_gaq.push(['_link', 'http://partner1.new-domain.com/']);
  return false;">
    Continue to the new site.
</a>

Hopefully this has cleared it up. I understand you do not want to use the setAllowLinker, but it is the best way.

More information here: Set up cross-domain tracking for multiple domains