Quantcast
Viewing all articles
Browse latest Browse all 12

Installing Multiple Google Analytics Tracking Codes

Your first reaction to this title is evident. Why would you, a good follower of Google’s principles, use two tracking codes? Now that sub-domain tracking and Cross-Domain tracking are available, you can direct data across sites to one single account. Given below are some scenarios where using only one tracking code doesn’t work:

1. You come across a messy implementation that already has multiple GA tracking codes and the client is paranoid that using one account might skew the data. In this case, the best you can do is to streamline the existing implementation.

2. You have multiple sites pertaining to different parts of an industry. For example:

  • You have a content website where you have information about general health checkup
  • You have a website where a user can schedule an a appointment to your clinic
  • You have a third website where you sell your set of CDs titled “How to stay fit forever”

In this case, you would want to view the data on a macro level; giving information on total visits, conversions, etc. and you would also want the micro level data to see how the individual properties are doing. Apart from this you would want to know how the properties are interacting with each other.

3. Psst, this one’s interesting: Since GA allows only 50 profiles per account, wouldn’t it be great if you could increase it to 100 or more? Of course, you’d be interested in this only if you have such a big site where you will need 100 profiles. Practically, you’d have 50 profiles each in two accounts.

In any of the above given examples, you cannot keep using just one GA account. You have to bring in another GA account and it’s tracking code. Have I convinced you enough?

Now, how to implement multiple tracking codes:

First, a snap shot of how a normal GA tracking code looks like:

Image may be NSFW.
Clik here to view.
B1

Now to include the second tracking code:

Image may be NSFW.
Clik here to view.
B2

You just have to add the above highlighted codes to the existing code and you’re now sending data two different accounts! Let’s analyze the new lines that you’ve added:

“secondTracker” is another object that you are creating within the JavaScript to differentiate it from the existing object that sends data to your default / first account. Similarly you can keep adding as many tracking codes as you want, but keep in mind that these are JavaScript codes that the browser has to execute and might increase the page load time a little.

Your next question: “What should I do if I want to enable event tracking and virtual Pageviews?” Here is what you do:

For a virtual page:

Image may be NSFW.
Clik here to view.
B3

 

 

The highlighted code snippet helps you to send the virtual pageview to the second account while the previous one is the default code sending the data to the default / first account.

For Event Tracking:  

Image may be NSFW.
Clik here to view.
B4

 

 

The highlighted code snippet helps you to send an event to the second account while the previous one is the default code sending the data to the default / first account.


Viewing all articles
Browse latest Browse all 12

Trending Articles