Search This Blog

Apr 18, 2011

Tracking website with Two (2) Google Analytics Account

I know that there should be a 1:1 ratio when installing Analytics tracking code to avoid any anticipated errors or data abruption. However, in some cases we need to install two asynchronous analytics tracking code for a single site. Example, Your clients wants to have different Google Analytics (GA) account instead of having a mutual one. So, in order to accomplish this task you need to set up an asynchronous code having two (2) different accounts.


1. GA tracking code is usually installed site wide.

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXX-1']);  //account 1
_gaq.push(['_setAccount', 'UA-XXXXXXXX-2']);  //account 2
(function() {
var ga = document.createElement(‘script’); ga.type = ‘text/javascript’; ga.async = true;
ga.src = (‘https:’ == document.location.protocol ? ‘https://ssl‘ : ‘http://www‘) + ‘’;
var s = document.getElementsByTagName(‘script’)[0]; s.parentNode.insertBefore(ga, s);

a. For static HTML Pages, put the above code between and in each HTML page you have.
b. For wordpress, put it between and in your theme header.php
c. Magento, you can put it in HTML head section under System  Configuration  Design.
d. For Drupal, you can put this under the page.tpl file of your theme.

2. Wait for a day to see tracked data in both analytics account.