?
Solved

How do I track two GA accounts on a website?

Posted on 2011-09-11
8
Medium Priority
?
426 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
Command Line Tips and Tricks

The command line is a powerful tool at the disposal of every Linux user. Although Linux distros come with beautiful user interfaces, it's worthwhile to learn the command line because it allows you to do a number of things that you otherwise cannot do from the GUI.  

 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying 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

Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.
Suggested Courses

752 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