Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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!

share|improve this question
add comment

3 Answers 3

up vote 18 down vote accepted

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']); 
_gaq.push(['_trackPageview']);

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..

share|improve this answer
    
someone on twitter also pointed out code.google.com/apis/analytics/docs/tracking/… –  Jeff Atwood Aug 11 '11 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 Aug 11 '11 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. –  Daniel Pehrson Aug 11 '11 at 13:20
    
Have you decided what approach you'll use for this Daniel? I have the same situation, and am curious... –  Michael D Aug 15 '11 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.) –  Daniel Pehrson Aug 19 '11 at 3:30
show 1 more comment

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.

share|improve this answer
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. –  Jeff Atwood Aug 11 '11 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. –  Daniel Pehrson Aug 11 '11 at 13:32
add comment

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.

share|improve this answer
1  
I think Google Analytics may actually recommend against this: code.google.com/apis/analytics/docs/concepts/… –  Daniel Pehrson Aug 12 '11 at 4:50
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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