Solved

How do I track two GA accounts on a website?

Posted on 2011-09-11
8
416 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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
 
LVL 23

Accepted Solution

by:
Tony McCreath 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:Tony McCreath
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

739 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