I'm confused by the Google documentation for analytics.js
Need to track cross domains, e.g. main-site.com blog-site.com
I set up a new property in Google Analytics and received the tracking code for main-site.com.
Step 1: Installed tracking code at page bottom in main-site.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-000000-X', 'main-site.com');
ga('send', 'pageview');
</script>
Step 2: instructions for analytics.js for cross domain (installed on main-site.com) Add the following before script ending tag.
// Load the plugin.
ga('require', 'linker');
// Define which domains to autoLink.
ga(‘linker:autoLink’, [‘main-site.com’, ‘blog-site.com’]);
Step 3: add tracking code to blog-site.com
// UA-000000-X is the tracking code number for main-site.com
ga(‘create’, 'UA-000000-X', {
‘allowLinker’: true
});
Problem: we need to track traffic that does not original in main-site.com. For example, a link from Facebook to blog-site.com should still count under the main-site property in GA.
For cross domain tracking you should be tracking the blog with the same tracking code number, so you will not have separate data for your blog and your main site, all the data will be in one place (if you want separate views of each site you need to set up additional profiles with profile filters to include only the traffic you want in that profile).
So if you're using the same tracking code for both, any visits to the blog (from e.g. facebook) should appear in that place. Is that not happening?