Implementation Detail
I was thinking about how to implement this. Currently, under Admin
-> Basic Setup
there are options ga universal domain name
and ga tracking code
. These options trigger the addition of this script for Google Analytics:
<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-1', 'auto');
ga('send', 'pageview');
</script>
To support this feature, we could add the option ga linked domains
. If that was blank, we would continue to emit the tag above. However, if it contained a comma separated list of domains, we’d adjust the tag to look like this:
<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-1', 'auto', {'allowLinker': true});
ga('require', 'linker');
ga('linker:autoLink', ['a.example.com', 'b.example.com', 'etc.example.com']);
ga('send', 'pageview');
</script>
The difference between these two is in the line that begins ga('create'
, and the two additional lines after it.
Workaround
In the meantime, I found that there’s a simple workaround. You can get this by using Admin
-> Customize
-> Text Context
-> Bottom of the pages
. I cleared my Google Analytics settings under Basic Setup
, and pasted the Google Analytics tag (with linked domains) into Bottom of the pages
.