Home > Uncategorized > Tacking multiple domains using Google Analytics

Tacking multiple domains using Google Analytics

If you have two or more domains / sites, it is a headache to track all of them using Google Analytics. Yes you can track 10 sites using 10 profiles, but you lost the whole picture. Here is how to track multiple domains using a single profile (so-called cross domains tracking).

Basically you have to do two tricks: a) modifying the google tracking js b)creating a custom filter to make the results more readable.

Let’s suppose you own two sites, www.orangecabin.com and www.google.com

Step 1 : Create profile

You have to decide which domain is the primary domain,  and create a normal profile for it as usual. Since www.orangecabin.com is more important (I hope so), you use it. It really doesn’t matter which one you use.

Step 2 : Customize tracking js

Now google show you the tracking javascript you are supposed to add to your site. Copy the js, save it to a file and edit it to something like this:

<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-4966487-9");
 
// tracking multiple domains
pageTracker._setDomainName("none");
pageTracker._setAllowLinker(true);
pageTracker._setAllowHash(false);
 
 
pageTracker._trackPageview();
} catch(err) {}</script>

These lines are added:

// tracking multiple domains
pageTracker._setDomainName(&quot;none&quot;);
pageTracker._setAllowLinker(true);
pageTracker._setAllowHash(false);

You will use this js instead of the original one.

Step 3 : Create a custom filter

The customized js is enough for google to collect information for all domains, but it won’t handle domain names correctly, www.google.com/index.html and www.orange.com/index.html will be reported as the same page. So you have to add a custom filter. If you don’t know what it is, don’t worry just follow me.

Return to the profile list,  find the newly created profile and click edit

multiple_domains_in_google_analytics_step_3_1

Find “Add Filter” on the new page

multiple_domains_in_google_analytics_step_3_2

Click “Add Filter”, Create it using these parameters:

Filter Name: MultipleDomains

Filter Type: Custom filter > Advanced

Field A: Hostname

Extract A: (.*)

Field B: Request URI

Extract B: (.*)

Output To: Request URI

Constructor: /$A1$B1

as shown on this image:

multiple_domains_in_google_analytics_step_3_3

Click save changes.

The next time you create another multiple-domain profile, you can reuse this filter instead of creating one.

step 4 add your customized js to your sites

 

That is it. Once you have enough data, you can get some report like this:

multiple_domains_in_google_analytics_step_4

Categories: Uncategorized Tags:
  1. January 18th, 2010 at 09:37 | #1

    Very easy to implement and provides great help for further Google Analytics segmentation on the websites. Thanks

  1. July 9th, 2009 at 08:46 | #1
  2. October 16th, 2009 at 18:06 | #2
Orange Cabin