0

I've created a site for a client and pasted Google Analytics script for both there account and mine.

My account seems to track fine, but their account does not, even though both accounts have been verified by Web Master Tools.

I've done this many times in the past but now notice GA's tracking code is slightly different.

Is there a new way to add multiple GA accounts to one site?

New Tracking code:

<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-12345678-5', 'mysite.com');
  ga('send', 'pageview');

</script>
  • I cannot say for sure. I will let someone else answer. But the ga create and send lines look like the key. The UA number is your account number found under GA Admin Account and the mysite.com is obvious. I think that a second set of ga create and send lines with the other account number would work. The UA number appears to be UA-accountnumber-1 where 1 may vary if you have more than one site. These things would have to checked, but that is my best guess. – closetnoc Mar 27 '14 at 3:57
  • did you sort this out? – phoops Mar 30 '14 at 9:21
1

You can install multiple instances of the Google Analytics tracking code on your web pages to send data to multiple properties in your account.

Not all configurations are supported. You can, for example, install multiple instances of the Universal Analytics tracking code (analytics.js) on your web pages but only one instance of the Classic Analytics code (ga.js). Multiple instances of ga.js might result in inaccurate data collection, processing, or reporting. You can, however, install one or more instances of analytics.js on web pages that also have a single instance of ga.js.

To use two new Universal Analytics trackers on one site, you need to initialize them and send pageView like this:

ga('create', 'UA-11112222-3', 'auto'); // first tracker
ga('create', 'UA-33334444-5', 'auto', {'name': 'newTracker'}); // second tracker

To send a pageview using both trackers, you prepend the name of the tracker to the beginning of the command, followed by a dot:

ga('send', 'pageview'); // send page view for first tracker
ga('newTracker.send', 'pageview'); // Send page view for second tracker.

If you, however, want to have tracking with new (Universal Analytics) and old (Classic Analytics) code, then these two trackers should both work.

If you, however, have one UA and one GA tracker on the page, they both should work without further configuration. Is it possible that there is some kind of error which prevents tracker from working?

If you are using chrome there is very useful extension to debug analytics tracking: https://chrome.google.com/webstore/detail/google-analytics-debugger/jnkmfdileelhofjcijamephohjechhna?hl=en

Sources:

  1. https://support.google.com/analytics/answer/1032400?hl=en
  2. https://developers.google.com/analytics/devguides/collection/analyticsjs/advanced#multipletrackers
  3. https://chrome.google.com/webstore/detail/google-analytics-debugger/jnkmfdileelhofjcijamephohjechhna?hl=en

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.