[2024 update] Google Analytics 4 does not have a feature similar to the customTask
instruction. As a result, unless you’re using the 360 version of GA4, you will need to send your tracking code multiple times, which is made easy with Google Tag Manager. A larger update to this post will follow.
If you own multiple websites, you’ve often wondered how to consolidate traffic data from all your Web properties (or apps) into a single view – besides Excel, that is!
Here is a quick guide on how to get this setup on all your sites, whether you use a tag management system or in-page tagging.
Let’s start with the basics
First off, this method is not new but seeing how many requests I get about setting up that kind of reporting, it was a good occasion to write up a guide 🙂
For Google GMP/360/Premium customers
You can use the Roll-up Property feature to achieve similar results. Ask your account representative to assist you.
For the first phase of this exercise, when we choose to consolidate traffic data, let’s start with the assumption that we only want high-level data because fine-level consolidation can cause issues.
Depending on your company’s jargon, you will want to differentiate between a “global” or “roll-up” property (where the consolidation happens) and a “local” account (limited to each site/app).
In this case, and for the purposes of this exercise, let’s say we got UA-123456789-1 as our new “global” property ID to consolidate traffic data across all our properties.
Let’s assume you use the following Google Analytics properties:
“Local” Site | “Local” Property ID | “Global” Property ID |
sitea.com | UA-12345-1 | UA-123456789-1 |
siteb.com | UA-23456-3 | UA-123456789-1 |
sitec.com | UA-34251-7 | UA-123456789-1 |
As you can see, depending on how much control/governance you have over your websites, you may have created different Google Analytics accounts and/or properties so hopefully when we consolidate traffic data, we’ll have a single data silo (property) to store everything. Great idea, right?
Setting up Google Analytics
Let’s start by setting up the property that will collect all the data. Assuming you already use more than one account for your online properties, let’s choose to use a new account just to consolidate traffic data:
- Go to Google Analytics
- Go to the Admin panel
- Create a new account and go through the property creation process
- Grab the new tracking code and/or property ID
Next, because our URL/screen structure may differ from site to site, let’s create a filter to replace the URL captured by Google Analytics with each site’s domain name or hostname. In Admin panel, go find your view and create a new filter (custom, advanced) with the following settings:
- Field A: Hostname: (.*)
- Field B: –
- Output field: Request URI: $A1
Great! That’s all there is to it – for now!
Now let’s adjust our tracking on all our websites to account for consolidation. It can be done easily using a tag manager (such as Adobe Launch, Google Tag Manager, Matomo, Tag Commander, Tealium…). If you still use page-based tracking code you will see this is not rocket science but can imply heavier changes. Let’s explore each method separately.
Using a tag manager to consolidate traffic data
Because you will more easily be exposed to the Google digital marketing ecosystem, this blog post will use Google Tag Manager but you can easily replicate this exercise with another TMS.
The easiest way is to create another Google Analytics tag for your roll-up property that fires along the same trigger as your “local” page view:
Of course this means specifying your new roll-up property ID in the tag definition, either as part of a Google Analytics Configuration Variable and/or as a “constant” variable to be used in a plain GA pageview tag or as part of said GA Configuration Variable:
Using the roll-up property ID in a Google Analytics configuration variable:
Our roll-up pageview tag is now pretty simple – just use the configuration variable! We will come back this topic later for advanced roll-up reporting.
Great, now go ahead and publish your container and automagically receive GA data in your roll-up property!
Extra credit: using Google Analytics’ customTask instruction
Google Analytics provides a robust JavaScript API with methods (tasks) to process data before it is sent to Google Analytics collection servers. One of these tasks is customTask, which you can use to do just about anything, including sending your Google Analytics payload (data) to more than one property by repeating a page view or an event.. I started fiddling with that notion but Simo was already writing about it 😀
In GTM, you’ll want to create a Custom JavaScript variable called GA Duplication with the following code:
function() {
// Replace newTrackingId value with the UA property to which you want to duplicate this tag
// or use the GTM variable placeholder
var newTrackingId = {{ID - Google Analytics - Roll-up}};
var globalSendTaskName = '_' + newTrackingId + '_originalSendTask';
return function(customModel) {
window[globalSendTaskName] = window[globalSendTaskName] || customModel.get('sendHitTask');
customModel.set('sendHitTask', function(sendModel) {
var hitPayload = sendModel.get('hitPayload');
var trackingId = new RegExp(sendModel.get('trackingId'), 'gi');
window[globalSendTaskName](sendModel);
sendModel.set('hitPayload', hitPayload.replace(trackingId, newTrackingId), true);
window[globalSendTaskName](sendModel);
});
};
}
Then use that variable as the hitCallback parameter in the Fields to Set section of your “local” GA tag:
Publish your container and bam! Double tracking! This solution is a lot more elegant (minimal effort and more inclusive) and does not require as much work. I encourage you to try this approach and read up on Simo’s post on the topic.
Using page-based tagging to consolidate traffic data
If you’re not a fan of tag managers or can’t/won’t install GTM on your site, that’s fine too, I guess. Now you’re going to modify each page on your site to support your roll-up strategy. If you’re good with PHP, Python, Java or whatever language drives your site, you can easily adjust your page templates to include a second pageview call. Having said that, you’ll want to take a few precautions; for instance using a different tracker name for your roll-up tracker would be a good idea to avoid conflicts:
<!-- 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','https://www.google-analytics.com/analytics.js','ga');
ga.create('UA-12345-1', 'auto', 'local');
ga('local.send', 'pageview');
ga.create('UA-123456789-1', 'auto', 'global');
ga('global.send', 'pageview');
</script>
<!-- End Google Analytics -->
In the above example for analytics.js, we are effectively duplicating the local pageview to the global property. If you use the global tag (gtag.js), the code now looks like this:
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-12345-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-12345-1', { 'groups': 'local' });
gtag('config', 'UA-123456789-1', { 'groups': 'global' });
gtag('event', 'Testing', { 'send_to': ['local','global'] });
</script>
In the above gtag.js code, you will notice you can create groups named after either the local or global tracker. The first two config calls send a pageview to each of the trackers separately but the event call is sending a GA event grouped call to both local and global. As you can imagine, you may need to re-tag your entire site, including events for clicks, eCommerce, etc.
Comparing methods
As I’m sure you gathered from the methods above, using customTask in GTM will save you a tremendous amount of time – assuming your properties and view are set up as identically as possible.
Pro tip
Whenever possible restrict development efforts by using a tag manager.
Viewing results in Google Analytics
Now that you’ve applied all my recommendations, you will start seeing roll-up data in your reports!
As you can see from the example above showing some of my own sites, this makes for quite the useful report!
This also means you can use Behavior Flow reports to see if your users navigate from site to site – assuming you set up cross-domain tracking.
And of course, this makes for awesome real-time dashboards:
Next steps
If you haven’t already done do, you should be using a data collection plan that is common across all your sites, or at least that provides a common measurement framework for most sites, with some flexibility for some sites.
This means making sure all your properties have the same setup when it comes to custom dimensions and metrics for instance: you don’t want to send irrelevant dimension data! This is one of the tremendous benefits of using the customTask method: you don’t need to redefine a Google Analytics Settings variable or redefine all custom attributes for the roll-up tracking call because it is going to inherit the attributes from the original call to the local property.
Here is a checklist to consolidate traffic data across properties:
- Review custom dimensions and metrics. If you have a large number of sites and dimensions/metrics, use my Python script or Simo’s Google Sheet.
- Review Remarketing and demographics settings: you may not be able to send targeting data the same way across sites.
- Maintain a list of sites and Google Analytics properties, assuming you share access using the same Google Analytics user account. You can also use the Google Analytics Management API for that
When should I worry about this?
Ideally, you should plan for this kind of tracking early when deploying multiple websites, it will make your life easier. But as we all know, projects can be tricky and you end up adding more tracking later one.
If you’re going to start out and not plan for consolidation right away, try to aim for simple tracking at the beginning before tacking on more tracking elements across all sites.
Just remember that it’s always more expensive if you do it later 🙂
In closing
Have you deployed multi-site tracking to consolidate traffic data across sites and apps?
What hurdles did you face? Did you identify success factors? Let me know in the comments!
This is a fantastic tip! I can’t wait to implement this to my various websites and track the interlinking data across websites.
These are time-saving tactics to consolidate traffic from your all websites in Google analytics. I will work on it to see the results.
Hey Julien!
You talk early in the article about the fact that a roll-up property may only be able to track high level data and that fine-level data may cause problems.
What kind of data will we be missing?
I have a few subdomains I need to track and I want to ensure I can track the same users across multiple subdomains. Obviously having these subdomains in the same property would be easiest, but I want the organizational benefits of placing them in their own properties and then creating the roll-up as well. However, I dont want to do this at the cost of valuable data.
hey sorry for mega-extra-late reply but if you build your URL structure or custom dimension definition with rollup in mind, you’ll be fine
Hi, this is one of the rare posts detailing pretty well how to create a rollup property with GTM. I’m not very good with javascript, but i’ll still ask. The example with the CustomTask (from Simo) works if we add only 1 new property to the rollup. But how would this look like if we had let’s say one or two more property to add? i just wonder how this custom javascript would look like. Thx.
Hi, this a great. How is it possible to combine traffic from different pages with ga4? Have you done this or do you know how?
Thx
Hi Michael,
GA4 will have rollup properties and subproperties where GA360 is enabled.
For free properties, you’ll have to use multiple tags to send data to multiple properties. This is made easier if you use Google Tag Manager.