Solved

How do I track two GA accounts on a website?

Posted on 2011-09-11
8
410 Views
Last Modified: 2013-12-09
I need to track all pages of a website for two separate GA accounts. The parent company wants to allow a partner to track the traffic but does not want them to have access to their Google Analytics Account.

Could someone please provide the correct code? I've seen examples but these seem to relate to cases where different sections needed to be tracked. All pages on the website concerned would have the same code.

Many thanks for any assistance provided
0
Comment
Question by:yorkshireladdie
  • 4
  • 2
  • 2
8 Comments
 
LVL 29

Expert Comment

by:David H.H.Lee
ID: 36526929
Hi yorkshireladdie,
You only need to grant to user permission in google analytic account to access your analytic reports.
Check this for more details how to configure it instead of working the analytic code:
http://www.google.com/support/analytics/bin/answer.py?answer=55500
0
 

Author Comment

by:yorkshireladdie
ID: 36528104
Thank you for your reply but I now have more background which paints a clearer picture of the problem.

The partner already has their own GA account and is historically tracking the data from the website concerned. The parent now want to track the data on their own GA account but don't want to go back to the partner - which I can understand. Hence the need to be able to track data on two GA accounts.

I appreciate your help and would be obliged for any assistance you can provide
0
 
LVL 29

Expert Comment

by:David H.H.Lee
ID: 36537876
yorkshireladdie,
I'm try to figure out if we are in the mutual understanding in solving this problem:

Original question post:
>>..The parent company wants to allow a partner to track the traffic but does not want them to have access to their Google Analytics Account.

Follow up your current environment:
>>..The partner already has their own GA account and is historically tracking the data from the website concerned.
The parent now want to track the data on their own GA account but don't want to go back to the partner
Does the new created GA Account in partner affect the latest GAresult? Do you still want to use same profile or creating new profile to refer the latest GA traffic, obsoleted the previous GA traffic?  You need to choose which GA to run in this case...

>> Hence the need to be able to track data on two GA accounts.
Generally, it is advisable to use same google profile to refer the GA result. In this case, you only need to grant the view traffic permission to specific GA Account as guided in my previous post.
Otherwise, you need to obsolete the previous GA traffic if your partner is referring new GA traffic using new GA Account instead of view GA via granted permission to access old GA details.
However, you can track multiple GA account under same web site, but you have to refer GA code separately into different landing page. This is depending how you control the strategy of your GA and the way you monitor the traffic as planned.
0
 

Author Comment

by:yorkshireladdie
ID: 36541274
Thank you very much for your reply and the points you have raised. I need to point out that the relationship between the two organisations is a trading one on this project only. There are no formal links between the two organisations.

For a number of reasons the Parent company do not want to go back to the Partner at this stage and ask them to

a) Cancel their existing tracking which is already set up and working on the partners GA account
b) Ask the Partner to give the Parent access to their GA account.

That is a situation which I cannot change.

It has been suggested that I can use this code below o achieve the objective. I appreciate this is not necessarily best practice but I need a workaround. Can you please advise whether the following script would work

<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-XXXXXXX-1']);
  _gaq.push(['_setDomainName', '.examplesite.eu']);
  _gaq.push(['_trackPageview']);
  _gaq.push(['_setAccount', 'UA-XXXXXXX-28']);
  _gaq.push(['_setDomainName', '.examplesite.eu']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>

Many thanks for your kind assistance

0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 23

Accepted Solution

by:
Tiggerito earned 500 total points
ID: 36546756
That won't work as you will override settings.

Try something like this:


<script type="text/javascript">

	var _gaq = _gaq || [];
	_gaq.push(['_setAccount', 'UA-XXXXXXXX-X']);
	_gaq.push(['_trackPageview']);

 // Second tracker 
	_gaq.push(['secondTracker._setAccount','UA-YYYYYYYY-Y']); 
	_gaq.push(['secondTracker._trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>

Open in new window

0
 

Author Comment

by:yorkshireladdie
ID: 36547563
Thanks very much for your assistance Tiggerito and your suggested script that's great.

Can you just confirm what you mean by overwrite settings? Do you mean the settings that are already established on an original account or something else?

Many thanks again for your help, its really appreciated.

0
 
LVL 23

Expert Comment

by:Tiggerito
ID: 36549490
I'm not fully clear in this myself, so this explanation may be wrong:

In both versions of the code we are creating a series of commands that get put on a queue for later execution, once the page is loaded.

In your example you are placing two commands in exactly the same place, which means the second _setAccount will overwrite the command made for the first _setAccount. With this you run the risk that the function of the first account you are tracking gets mixed up with settings from the second account and it does not track properly.

In my example the second set of commands are added in a special namespace (secondTracker) which means the are somewhere else and don't directly interfere with the first commands.

Something like that anyhow ;-)



0
 

Author Closing Comment

by:yorkshireladdie
ID: 36566649
Absolutely brilliant - thanks very much that works perfectly.

Sorry for the delay in awarding the points but I was away for the weekend.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Read about how to choose the best possible content marketing agency to suit your needs. Content marketing has become an integral part of running a successful tech business, so it is wise to be informed.
I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now