I am trying to embed a GA code in my website that is based on the new Universal Analytics method. What I am trying to achieve is to send data to multiple properties from one page.
So I have checked the official GA documentation on the new universal GA code and specifically the section about "Working with multiple tracking objects".
https://developers.google.com/analytics/devguides/collection/analyticsjs/advanced#multipletrackers
But so far without success.
I have one domain for the standard website www.website.de and another one for the mobile website de.website.mobi.
My GA code for my standard website looks like this:
(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-1');
ga('create', 'UA-12345678-2', {'name': 'newTracker'});
ga('send', 'pageview');
ga('newTracker.send', 'pageview');
In the GA real time section I can see that the property UA-12345678-1 is getting real time results but the the second property isn't getting results at all.
Does anybody know the reason? Am I mistunderstanding the GA documenation.
To clarify: On my mobile website I would like to embed the following code:
(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-1');
ga('create', 'UA-12345678-3', {'name': 'newTracker'});
ga('send', 'pageview');
ga('newTracker.send', 'pageview');
So, I have three properties: UA-12345678-2 for the standard website, UA-12345678-3 for the mobile website and UA-12345678-1 as an aggregation of both giving me the opportunity to see the results of standard website and mobile website summed up. At least that is what I am trying to achieve.
Any ideas are welcome.