?
Solved

Google Analytics - Two Seperate Tracking Urchins?

Posted on 2010-11-27
4
Medium Priority
?
285 Views
Last Modified: 2013-11-18
Hello,

I run a group of sites, each of which currently is attached to a Google Analytics account for per site tracking. There are 76 sites in total.

Now because of my business model, it is also really important to track the group, as a group, rather than have 76 different reports to collate data from.

So each site currently has something like this within each pages code -

<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-19999999-99]);
  _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>

Can I add to this with another group code like so

[First site specific google code]
<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-19999999-99]);
  _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>
[Second Group Specific Code]
<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-19999999-66]);
  _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>

I'm more than happy on the group one to track (inter-group) traffic from one site within the group to another, so don't need to discount this....

Really grateful for any thoughts suggestions regarding this, please.

Thanks Experts
0
Comment
Question by:garethtnash
[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
  • 2
4 Comments
 
LVL 31

Accepted Solution

by:
James Murrell earned 1000 total points
ID: 34223412
hello this is a must read for you http://www.optimiced.com/en/2007/10/25/two-or-more-google-analytics-in-one-page/

not easy but it can work
0
 
LVL 23

Assisted Solution

by:Tony McCreath
Tony McCreath earned 1000 total points
ID: 34224000

This code should work.

Note that the second two tracker lines have a different account and the commands are prefixed with an account name (second.)
<script type="text/javascript">

  var _gaq = _gaq || [];

  // first
  _gaq.push(['_setAccount', 'UA-19999999-01]);
  _gaq.push(['_trackPageview']);

  // second
  _gaq.push(['second._setAccount', 'UA-19999999-99]);
  _gaq.push(['second._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:garethtnash
ID: 34232744
Thanks Both, but neither appears to work :( any suggestions?

thank you
0
 

Author Comment

by:garethtnash
ID: 34233276
ignore me - thanks both
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them.

Question has a verified solution.

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

Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
Choosing a core focus or particular set of features and options can be tough. To help out, we’re going to highlight a handful of things your business needs on one of your social media pages. In other words, if one of these is missing, you should imp…
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
Suggested Courses

762 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