I currently run a small web-app that connects local businesses with new customers in a very specific niche. In the past few months this model has worked very well and the growth is excellent, so much so in fact that I'm preparing to expand the app to support multiple sites/niches. Ultimately it will be structured very similarly to StackExchange in that each site will have it's own domain, design and focus, but running off of the same platform.

With that said, I've been trying to think of the best way to handle the analytics (specifically Google Analytics) for this setup.

My two requirements are basically that I want to be able to see aggregate statistics for all sites so that I can get an overview of how the system is performing generally on a day-to-day basis, but also be able to narrow down to specific site and track at that level for SEO, marketing, and debugging purposes.

What I'm hoping is that other people who may have done this or have more experience with Google Analytics may be able to tell me whether I would be better off creating one multi-domain analytics profile (and figuring out how to break it out by site) or creating a profile for each site and having the unique profile id configured with the sites in my system.

From a development standpoint I would much rather do the former.

Thank you in advance for your time and insights!

3 Answers 3


Neither method is perfect; both have their pros and cons.

It is definitely simpler to have one distinct Google Analytics key for every domain or subdomain. There is no question about this. However, that breaks down when you have, say, dozens or hundreds of domains.

If you have many SUBdomains using the same Google Analytics key, you must push the domain name on each request, like so.

var _gaq = _gaq || []; 
_gaq.push(['_setAccount', 'UA-5620270-24']); 
_gaq.push(['_setDomainName', '.stackexchange.com']); 

Then you can segment fairly easily based on Hostname... just use the Advanced Segments dropdown in the top right and create a segment for hostname="gaming.stackexchange.com" or something similar. You can even make aggregate segments hostname="gaming.stackexchange.com" OR hostname="webapps.stackexchange.com" OR hostname="cooking.stackexchange.com" etc.

If you have many different domains, it's much harder.

Call the _link() method in any links between the domains. If your current links have the form:

<a href="https://www.secondsite.com/?login=parameters">Login Now</a>

change them to:

<a href="https://www.secondsite.com/?login=parameters" onclick="_gaq.push(['_link', 'http://www.firstsite.com']); return false;">Login Now</a>

For different domains, we simply use different Google Analytics keys..

  • someone on twitter also pointed out code.google.com/apis/analytics/docs/tracking/… Commented Aug 11, 2011 at 4:55
  • One more thing to take in consideration here. Will you be showing the stats to different clients? Then I would go with seperate IDs
    – baldy
    Commented Aug 11, 2011 at 5:14
  • The analytics are only for internal use, no one else needs access. It's more that we would have one site for camping stores, one site for fishing stores, etc.
    – THREE
    Commented Aug 11, 2011 at 13:20
  • Have you decided what approach you'll use for this Daniel? I have the same situation, and am curious...
    – Michael D
    Commented Aug 15, 2011 at 17:19
  • 1
    I am going to try out the latter option ( google.com/support/analytics/bin/… ) and see how it goes. This implementation is most likely a few months away at least though (I plan ahead.)
    – THREE
    Commented Aug 19, 2011 at 3:30

There is further information about cross domain tracking here. As Jeff mentioned, cross domain tracking is not for the faint hearted but can be achieved with a few lines of jQuery code that picks out the links and adds the oppropriate tracking call. You may also need to add tracking calls to forms if they post between the domains.

If you are trying to see how your network of sites is performing as a whole and perhaps setup goals that involve multiple sites it is really the only way to go.

  • 1
    yeah, kinda scary that true cross-domain analytics (with the same key) requires you to "touch" every hyperlink on the page, but it seems unavoidable. Commented Aug 11, 2011 at 5:34
  • 1
    What's interesting is that based on my reading of the documentation it only appears that you need the link javascript on cross-site links, which will be very rare if at all among my network (the sites are all really meant to be independent silos just running on the same platform.) Every once in a while one might link to another similar site in the header but it would not be prevalent.
    – THREE
    Commented Aug 11, 2011 at 13:32

Use both! It's at the cost of page loading times, but it will give you detailed statistics.

Normally both code blocks don't conflict with each other.


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.