Google Analytics SubDomains Tracking Part One

by Kieran Flanagan

Friday, March 27th, 2009

11 Comments

0010

So I have recently been setting up a rather large implementation of Google Analytics as part of a holistic SEO strategy and had the joy of doing this over a site with a large number of sub domains. There are a number of things to keep in mind when implementing Google Analytics tracking for sub domains:

What makes this an even more interesting implementation is the conversion process. A user can search for a product on the sub domain sites but is then redirected back to the conversion steps on the main site:

– User searches for product on subdomain_1.mainsite.com
– User is referred to www.mainsite.com/booking_step
– User goes through steps to www.mainsite.com/confirmation

I also had a problem where by the steps on the conversion process were dynamic URLs, so it was a little more complicated to create goals.

Set up our Sub domain Tracking and Funnels

To Do

1. setDomainName: First you need to add the following tracking code to all pages of your subdomains and main domains.

2. Virtual Pageviews: You can then setup virtual pageviews for steps in your conversion process that have dynamic URLs

pageTracker._trackPageview(‘Step_1′);

NOTE: Be careful with the above. If you have trackPageview twice on the same page, your referral will be reset and all conversions will show as direct.

3. You need to set up an advanced filter to attach the sub domain to the front of each page. If you don’t do this and you have the same page on both your main site and sub domains, you will not be able to distinguish between either i.e.

4. Trying to break down the funnels by sub domain proved another obstacle altogether as each sub domain refers back into the main sites conversion process. So for example I have one funnel setup to track the conversion process as follows:

But to break this funnel down by sub domain you need to be a little more inventive. You can do a lot of different things:

a. Create Advanced Segments to do the following
– Track users who landed on a particular page (your sub domain) and went on to convert (using the Ecommerce Affiliation field).

b. Create a funnel using the advanced filter used above. This will allow you to create goal steps as follows:

– The first required step will check to see if a user is on any page of your sub domain (as a regexp) i.e. /subdomain_1\.mainsite\.com/.*
– Step 1 (On main site – required step)
– Step 2 (On main site)
– Confirm Booking (On main site)
– Thank You Page (On main site)

This is not the whole Google Analytics story on sub domains. There is the case of tracking between multiple domains with sub domains and also tracking conversions when users are redirected to a third party shopping cart. I will add these in Part 2.

I have tried a bunch of things and for some reason it never registers the sub.domain.com in any of my goals.

Can you shed some light on this?

Thanks!
Oscar

http://www.searchbrat.com Kieran Flanagan

Hi Oscar

Do you have your tracking code setup on all pages as follows:

With the setDomainName used. This will ensure all sub domains are counted as part of your main site.

Let me know if this helps

Thanks

Kieran

http://www.searchbrat.com Kieran Flanagan

Sorry Oscar the code I pasted above didn’t get shown. You can see in my post above, I give an example of how the tracking code should look on each page. Under point 1.

Tim Day

I have a quick question in terms of this. We’re hosting one of our sub-domains as http://www.subdomain.domain.org.au, with the extra “www” preceding the subdomain, and for some reason, this site isn’t being tracked. All the code is set up as described above, and one one profile where I limit it to just the subdomain it comes through fine, but not the profile set to track all subdomains. Any ideas why?

cheers,
Tim

Tim Day

Please ignore that last question – I had a typo in my filter constructor. New to this!

http://www.searchbrat.com Kieran Flanagan

No problem Tim, let me know if you ever need a fresh pair of eyes to look at anything

gil_34

I am desperate with this filter. Our agancy implemented the additional line pageTracker._setDomainName(“.mainsite.com”); to the tracking code but still after integrating the filter we have strange reports. Some sites are shown with domain names and some are not. And is is right that pages with domains appear with / before in analytics like this: /www.mydomain.com/? (this is the case when analytics shows the domain)

Maybe there is something wrong within the tracking code? The tracking code in our main domain looks like this: