Skip to content

Set up an Universal Analytics roll-up property using Javascript

What is a roll-up property ?

Imagine you have to implement analytics for an international customer. It owns several hundred of websites (one website / analytics property / domain name per country).

It will be interesting to analyze the aggregated data to see global performance metrics, and  drill down to compare brand performance among countries.

This is the purpose of roll-up properties. A roll-up property aggregates data from multiple account properties.

If you track a website set up for serveral european countries (with serveral dedicated domains),it may be really interisting to set up a roll up property in order to aggregates analytics data from all the european properties.


Roll-up properties exist in other Digital Analytics solutions (such as Adobe Analytics).

If you want to set up a standard roll-up property using Google Analytics 360, you can have a look at the Google Analytics official documentation.

Why should I set up a roll-up property in javascript ?

Using Google Analytics, you can officially only set up a roll-up property if you have Google Analytics 360. Indeed, users of the free version cannot set up such a property the standard way.

Moreover, roll-up properties cannot aggregate hits that do not belong to the same Google Analytics account.

How to implement a roll-up with Javascript ?

You need to declare a function that will enable you to forward all your GA hits to the roll-up property. This is the intent of the "gaRollup" function bellow :

window.gaRollUp = function() { 
    var b = arguments[0]  , e = arguments, c = arguments; 
    e[0] = "Local." + b;, e); 
    c[0] = "International." + b;, c);

Before any use of this function, you will have to create the trackers. In this example, the markers had been named"Local" (for the local property), and the "International"  property (the roll-up property).

ga('create', 'UA-XXXXX-Y', 'auto', {name='Local'});
ga('create', 'UA-XXXXX-Y', 'auto', {name='International'});

Rather than using the usual "ga" function, you will have to use the "gaRollUp" function to send GA hits to these two properties.

For instance, the javascript code below :

gaRollUp('set', 'dimension1', 'homepage');
gaRollUp('send', 'event', 'lorem', 'ipsum', {eventValue:2});
gaRollUp('send', 'pageview');

will send Javascript hits to both the "local" property and the "international" (roll-up) property.

Mind the property configuration : dimensions, metrics, content grouping should be set up exactly the same in the different properties.

There is another method for this : you can also write your own roll-up plugin. This trick has been explained in the great blog post of Simo Ahava.

And with Google Tag Manager ?

Usual way

It is very easy to set-up if you use custom HTML tags.

Thus, it not that easy to set-up a roll-up propery using the official Universal Analytics Tags. Moreover, you cannot set up a custom analytics plugin inside Universal Analytics tags of GTM.

Sometimes, people duplicate Universal Analytics tags (pageview, events...) to create a roll-up,but in my opinion, the setup is then harder to maintain. I do not recommand it.

Using the new API task

A new API has been released recently, to redefine the behaviour of analytics.js (for instance, the way GA hits are sent).

This API can be used with Universal Analytics tags in Google Tag Manager.

For this, you have to declare a custom javascript variable. I named it "GA sendHitTask Rollup".

function() {
  return function(model) {
    var originalSendTask = model.get('sendHitTask');
    model.set('sendHitTask', function(sendModel) {
      sendModel.set('hitPayload', sendModel.get('hitPayload').replace({{gaProperty}}, {{gaRollupProperty}}), true);

"gaProperty" et "gaRollupProperty" variables contains respectively the property identifier  (UA-XXXX-Y) of the local property and the roll-up property.

This function will send the google analytics hits to the local property, and then to the roll-up property.

To be honest, this code has been copied and paste from a blog post of Simo Ahava.

Once the  "GA sendHitTask Rollup" variable has been created, you need to set  up the "Google Analytics settings" variable and assign customTask" to the "GA sendHitTask Rollup" function.

The reguired GTM setting to implement the roll-up

Now all the Universal Analytics hits will be sent to two different properties : the usual (local) one, and the roll-up property.

4 thoughts on “Set up an Universal Analytics roll-up property using Javascript

  1. Diane

    Thanks a million for this precious time saver !
    Using GTM, I was wandering if there was some workaround way to set up a roll-up property without having to duplicate all my tags ... and I stumble upon your excellent article .

  2. Pelletrat

    Dear Antoine,

    I hope that you are doing well.

    I decided to put it to the next level :), and now find myself struggling to achieve a hit being send to one single site property, and a modified one sent to a rollUp property.
    The idea is to place a customTask on each tag of the single site, that will first send the hit to this property and then modify the payload to send another hot to the rollUp property.

    I know that in the hit sent to the rollUp property, I have to change two parameters : allowLinker should be set to true, and cookieName set to _gaRollUp.

    As I said, I am struggling to produce the custom variable that will be called by te customTask.
    I am pretty sure I did something dum, but here is what I came up with :
    If you could just give me a hint, I will be really grateful 🙂

    Have a lovely day,

    All the best,


    function() {

    // Specify the GA tracking ID of the property to which you want to duplicate the hits
    var gaRollUpProperty = {{gaRollUpProperty}};
    var cookieName={{cookieName}};

    return function(model) {

    var originalSendTask = model.get('sendHitTask');

    model.set('sendHitTask', function(sendModel) {

    originalSendTask(sendModel); // sends the hit to the site Property
    siteProperty = new RegExp(sendModel.get('trackingId'), 'gi');
    hitPayload = sendModel.get('hitPayload');
    buildHitTask= sendModel.get('buildHitTask');
    sendModel.set('hitPayload', hitPayload.replace(siteProperty, gaRollUpProperty), true);
    model.set('hitPayload', hitPayload.replace(allowLinker:false,allowLinker:true), true);
    model.set('hitPayload', cookieName:'_gaRollUp');


Leave a Reply

Your email address will not be published. Required fields are marked *