Mobile app version of vmapp.org
Login or Join
Goswami781

: 2nd Google Analytics account not working 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

@Goswami781

Posted in: #GoogleAnalytics #GoogleSearchConsole

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>

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Goswami781

1 Comments

Sorted by latest first Latest Oldest Best

 

@Steve110

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: chrome.google.com/webstore/detail/google-analytics-debugger/jnkmfdileelhofjcijamephohjechhna?hl=en
Sources:

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

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme