[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How do I track two GA accounts on a website?

Posted on 2011-09-11
8
Medium Priority
?
437 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
Sign your company up to try the MB 660 headset now

Take control and stay focused in noisy open office environments with the MB 660. By reducing background noise, you can revitalize your office and improve concentration.

 

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 2000 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

Looking for a new Web Host?

Lunarpages' assortment of hosting products and solutions ensure a perfect fit for anyone looking to get their vision or products to market. Our award winning customer support and 30-day money back guarantee show the pride we take in being the industry's premier MSP.

Question has a verified solution.

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

In today's business world, data is more important than ever for informing marketing campaigns. Accessing and using data, however, may not come naturally to some creative marketing professionals. Here are four tips for adapting to wield data for insi…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
This video teaches users how to migrate an existing Wordpress website to a new domain.
Suggested Courses

656 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