Reputation: 1450
I recently started to use multiple domain tracking code setup as outlined at https://support.google.com/analytics/answer/1033876?hl=en-GB&ref_topic=2772342 and trying to mix that with the existing domain properties existing GA tracker codes.
But the multiple domain tracking code isn't showing any data or being picked up when I look at the multiple domain tracker web property's tracker status?
I am at a loss at what the problem is. Using GA Debugger extension for Chrome reveals 2 GA trackers outputting identical data including identical account UA-XXXXXXX ids.
Background:
I have 3 web properties all on same domain1.comm, 2 use subdomains. So all up the 3 web properties are
Each property has it's own GA web property and unique tracker code for separate tracking originally. And was something like this
<script type="text/javascript">
var _gaq=_gaq||[];_gaq.push(['_setAccount','UA-XXXXXXX-1']);
_gaq.push(['_setDomainName','domain1.com']);
_gaq.push(['_setSiteSpeedSampleRate',100]);
_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>
Now I want to add a 2nd tracker to each of the 3 web properties for multiple domain tracking across all 3 web properties so set it up as follows
for domain1.com
<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-XXXXXXY-2', 'auto', {'allowLinker': true});
ga('require', 'linker');
ga('linker:autoLink', ['forum.domain1.com, 'blog.domain1.com'] );
ga('send', 'pageview');
</script>
for forum.domain1.com
<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-XXXXXXY-2', 'auto', {'allowLinker': true});
ga('require', 'linker');
ga('linker:autoLink', ['domain1.com, 'blog.domain1.com'] );
ga('send', 'pageview');
</script>
for blog.domain1.com
<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-XXXXXXY-2', 'auto', {'allowLinker': true});
ga('require', 'linker');
ga('linker:autoLink', ['domain1.com, 'forum.domain1.com'] );
ga('send', 'pageview');
</script>
Adding SiteSpeedSampleRate
Also to add SiteSpeedSampleRate to multiple domain tracker code, is this correct ?
<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');
_gaq.push(['_setSiteSpeedSampleRate', 100]);
_gaq.push(['_trackPageview']);
ga('create', 'UA-XXXXXXY-2', 'domain1.com');
ga('send', 'pageview');
</script>
Upvotes: 0
Views: 626
Reputation: 2452
Since you're on the same domain with just different subdomains, you don't need to use the autolink. Just set the cookie domain to the highest level (domain1.com). Also, if you're running multiple trackers on the same page, you'll need to give them their own namespaces.
(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');
/* Assuming the existing properties are migrated to Universal Aanlytics - which they should be */
ga('create', 'UA-XXXXXXX-1', 'domain1.com');
ga('send', 'pageview');
/* Note the inclusion of the name property */
ga('create', 'UA-XXXXXXY-2', 'domain1.com', {'name': 'multi'});
ga('multi.send', 'pageview');
Upvotes: 2