Analytics
4.8K members online now
4.8K members online now
Learn how to set up goals and Ecommerce tracking, verify accuracy of attribution traffic sources, and discuss funnel visualization, Multi-Channel Funnels, the Goal Flow Report, and Enhanced Ecommerce
 
Guide Me
star_border
Reply

Tracking 1 Site, Multiple GA Properties - Simple?

Follower ✭ ✭ ☆
# 1
Follower ✭ ✭ ☆

I just need a quick bit of advice.

 

I need to add 2 universal codes to a website. Is it simple adding the other tracking ID (shown in red below):

 

(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','__gaTracker');

 

__gaTracker('create', 'UA-xxxxxx-1', 'auto');

__gaTracker('create', 'UA-xxxxxx-2', 'auto');
__gaTracker('send','pageview');

1 Expert replyverified_user
1 ACCEPTED SOLUTION

Accepted Solutions
Marked as Best Answer.
Solution
Accepted by topic author Help P
November 2015

Re: Tracking 1 Site, Multiple GA Properties - Simple?

Top Contributor
# 2
Top Contributor
Hi Help P,

If you deploy multiple trackers on your site, you will need to name at least one or both of your trackers. Currently, the way you have things set up, you will cause some confusion with your analytics as both trackers are not named, and hence you could be sending hits to the wrong properties and polluting your data. What you just need is the following:

__gaTracker('create', 'UA-ABCDEF-G', 'auto');
__gaTracker('create', 'UA-HIGJKLM-N', 'auto', 'tracker2');
__gaTracker('send', 'pageview'); // this sends the pageview for the first, unnamed tracker
__gaTracker('tracker2.send', 'pageview'); // this sends the pageview for the second named tracker

Anytime you want to send hits for either of the trackers, you either send without a name and the hits will go to the first tracker, or you send with the name prepended and send hits to the second tracker.

You can find more details here: https://developers.google.com/analytics/devguides/collection/analyticsjs/creating-trackers

Hope this helps.
Nicky Yuen, Google Analytics Top Contributor
Was my response helpful? If yes, please mark it as the ‘Best Answer.’ Learn how here.
Find me on: Google+ | LinkedIn

View solution in original post

Marked as Best Answer.
Solution
Accepted by topic author Help P
November 2015

Re: Tracking 1 Site, Multiple GA Properties - Simple?

Top Contributor
# 2
Top Contributor
Hi Help P,

If you deploy multiple trackers on your site, you will need to name at least one or both of your trackers. Currently, the way you have things set up, you will cause some confusion with your analytics as both trackers are not named, and hence you could be sending hits to the wrong properties and polluting your data. What you just need is the following:

__gaTracker('create', 'UA-ABCDEF-G', 'auto');
__gaTracker('create', 'UA-HIGJKLM-N', 'auto', 'tracker2');
__gaTracker('send', 'pageview'); // this sends the pageview for the first, unnamed tracker
__gaTracker('tracker2.send', 'pageview'); // this sends the pageview for the second named tracker

Anytime you want to send hits for either of the trackers, you either send without a name and the hits will go to the first tracker, or you send with the name prepended and send hits to the second tracker.

You can find more details here: https://developers.google.com/analytics/devguides/collection/analyticsjs/creating-trackers

Hope this helps.
Nicky Yuen, Google Analytics Top Contributor
Was my response helpful? If yes, please mark it as the ‘Best Answer.’ Learn how here.
Find me on: Google+ | LinkedIn

Re: Tracking 1 Site, Multiple GA Properties - Simple?

Follower ✭ ✭ ☆
# 3
Follower ✭ ✭ ☆
Hi Nicky Y

This is perfect, thanks!

Re: Tracking 1 Site, Multiple GA Properties - Simple?

Follower ✭ ✭ ☆
# 4
Follower ✭ ✭ ☆
Hi Nicky Y,

So, I've implemented the code and the 2nd tracker is not working:

<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-fffffff-1', 'auto');
ga('create', 'UA-dddddff-2', 'auto', 'fulltracker');
ga('send', 'pageview');
ga('fulltracker.send', 'pageview');

</script>

Thankfully, the 1st tracker works but I'm getting no recorded sessions in real time reports for the 2nd. Any advice?

Re: Tracking 1 Site, Multiple GA Properties - Simple?

Top Contributor
# 5
Top Contributor

Try entering it like this:

 

ga('create', 'UA-dddddff-2', 'auto', {name: 'fulltracker'});
Nicky Yuen, Google Analytics Top Contributor
Was my response helpful? If yes, please mark it as the ‘Best Answer.’ Learn how here.
Find me on: Google+ | LinkedIn

Re: Tracking 1 Site, Multiple GA Properties - Simple?

Follower ✭ ✭ ☆
# 6
Follower ✭ ✭ ☆
Thanks, that did the trick!