Wednesday, May 8, 2024
HomeWeb AnalysisHow to send the same data to multiple properties in Google Analytics?

How to send the same data to multiple properties in Google Analytics?

We’ve used this technique on one or two occasions in the past to send the same tracking data to multiple properties. Since there is almost no such need, I did not introduce it on the blog, but I heard from some people that “this method is useful”, so I will write an article.

 

Use scene

As a typical usage scene, in “implementation of Google Analytics across multiple domains”, you want to create a property that measures data across all domains after measuring data on the property of each individual domain. I have a case. In such a case, if you have various customizations in individual properties, it will be a lot of work to implement them in all domain crossing properties. In such a case, “How to send the same data to multiple properties” this time will be useful.

prerequisite

It is assumed that you have implemented the Google Analytics tracking code using Google Tag Manager. However, the idea itself does not rely on Google Tag Manager, so you can use it even if you have directly implemented the tracking code.

In addition, the information being sent is not only a simple page view, but various event tracking is implemented, and it is assumed that it would be difficult to simply copy all existing tags and change only the destination. I’m here.

In addition, it is also a condition that you use the ” Google Analytics Settings ” variable in Google Tag Manager . With this function, you can combine Google Analytics setting information into one variable and share it with multiple Google Analytics tags (including events, etc.). If you have a lot of Google Analytics tags, I recommend using them.

Ideas for customization

The idea is to use a function called “task function” that was implemented about 4 months ago. The task function is a function that allows arbitrary processing to be inserted between each processing when Google Analytics data is sent. In addition to inserting arbitrary processing, you can also rewrite the value to be sent at this timing or cancel the transmission under certain conditions.

This time, we will use this task function to implement the process of acquiring the information when the underlying tracker sends it to Google Analytics and sending it to another property.

Customized content

Create custom JavaScript variables

First, create a “variable” of your custom JavaScript type. Here, the variable name is “Function – customTask”. The contents of the JavaScript are as follows.

function () {
  return function(model) {
    var keys = "hitType page eventCategory eventAction eventLabel eventValue".split(' ');
    var params = {};
    for (var i = 0; i < keys.length; i++) {
      if (model.get(keys[i])) {
        params[keys[i]] = model.get(keys[i]);
      }
    }
    ga('create', 'UA-xxxxxxx-y', {name: 'second'});
    ga('second.send', params);
  };
}

Define the parameters to copy the values ​​in the keys variable, get them from the model variable and set them as parameters for sending. It then creates a new tracker and sends the copied and created send parameter values ​​to the new tracker.

In some cases,

ga('create', 'UA-xxxxxxx-y', {name: 'second'});

By overwriting the params variable before , it is possible to have the second tracker send slightly different information than the basic tracker.

Also, it is necessary to adjust the keys variable so that the appropriate parameter names are included according to the contents set in each tag.

Register in GA tag as customTask

At this time, if Google Analytics variables are used, it is convenient because you only need to change one place.

Select “Fields to set” from “Advanced settings” of Google Analytics variables and add one field. Enter “customTask” in the field name and set the variable “Function – customTask” created earlier in “Value”.

I have prepared a captcha for your reference.

Perform operation test and publish

Up to this point, the implementation of sending to multiple trackers is complete. After that, check the operation in preview mode, and if there is no problem, publish it. As a point of caution, in the case of using a custom dimension, in that case, it is necessary to align the index of the custom dimension of multiple properties or map it correctly in “Function – customTask”.

summary

In this article, we introduced a mechanism for sending the same information to multiple trackers. It may be difficult to use, but I think it’s a customization method that is beneficial to know in case of emergency.

RELATED ARTICLES

Leave a reply

Please enter your comment!
Please enter your name here

Recent Posts

Most Popular

Recent Comments