Wednesday, November 22, 2023
HomeWeb AnalysisHow to batch migrate UA tags implemented in GTM to GA4 ?

How to batch migrate UA tags implemented in GTM to GA4 ?

According to a monthly survey article by SEM Technology, the adoption rate of GA4 has reached over 9% as of the end of September 2021. In order not to be left behind by this trend, many people are probably considering introducing GA4 tags soon.

In this article, we will explain the ” GA4 GTM Migration Tool ” , an unofficial migration tool provided by Google, and how to use it.

What is GA4 GTM Migration Tool?

“GA4 GTM Migration Tool” is an open source tool developed by Google (managed by Github) that migrates (upgrades) the Universal Analytics tags implemented in Google Tag Manager to GA4 tags. (However, it is not a Google product officially supported by Google).

This tool runs on Google Sheets and has a relatively easy-to-use interface even for non-engineers.

This tool works by manipulating the Google Tag Manager API from a Google Spreadsheet script. When executed, it does not make any changes to existing triggers and variables, reads the settings of existing Universal Analytics tags, and prepares to migrate the information set in each tag to GA4. However, it is not the kind that can be migrated completely automatically, and there are many things that need to be set by yourself on a spreadsheet, such as “what event name to send” and “parameter name of event parameters”. I have.

It’s not a magic tool that will create a GA4 implementation in one click, and I don’t think there will be such a magic tool in the future.

For how to use the GA4 GTM Migration Tool, there is an English version in the Github repository “google/ga4-gtm-migration” , so please refer to this help as primary information.

How to use GA4 GTM Migration Tool

It will be a little longer from here, but I will explain how to use the “GA4 GTM Migration Tool” step by step. Since it is a tool that is currently being updated, there is a possibility that the procedure will change due to future version upgrades, but I think that the movement will basically be the same.

1. Join Google Group

In order to view the spreadsheet that serves as the template for 2, it is currently necessary to join the prescribed Google group. Google Group does not require approval, and it seems that anyone can join the group immediately if they apply.

Join the Google Group at the link below.

2. Copy the template spreadsheet

Next, prepare a spreadsheet in which the implementation of this migration tool is done. If you joined the Google group in 1, you can access the template spreadsheet.

This template spreadsheet has only viewing permissions, but it can be copied, so let’s copy this spreadsheet and create your own editable spreadsheet.

3. Authenticate for API execution

When you reload the copied spreadsheet, “GTM Migration” appears in the menu bar. This menu bar “GTM Migration” is used for subsequent API calls. Here, click ” Authorize Permissions ” in this to authorize your own Google Tag Manager operations from this spreadsheet.・Authenticate.

4. Specify the Google Tag Manager container to be migrated

Specify the Google Tag Manager container to be migrated. The specification method is not to enter only the container ID, but to enter the URL when the corresponding container is opened on the web management screen as it is.

Copy and paste the URL of the web management screen into cell “B1” of the “GTM URL” sheet of the spreadsheet.

5. Page view migration

“Pageview Migration” uses the “Pageview Migration” sheet in the spreadsheet. Let’s move on to this sheet.

5.1. Listing GA setting variables

This extracts the “Google Analytics setting variables” set in Google Tag Manager.

The extracted “Google Analytics setting variables” information is output in columns A to E. In the capture below, there is only one target Google Analytics setting variable, but if multiple Google Analytics setting variables are registered in Google Tag Manager, only that number will be displayed.

Check the E column of the Google Analytics setting variable to be migrated from the listed Google Analytics setting variables, and enter the measurement ID of the corresponding Google Analytics 4 data stream in the D column.

5.2. Listing GA pageview tags

Select “GTM Migration > Pageview Migration > List UA Pageview Tag” on the menu bar. This will extract the “Google Analytics” page view tag linked to the GA setting variable specified in 5.1.

The Google Analytics page view tag associated with the Google Analytics setting variable to be migrated is displayed in columns G to J. Set the GTM tag name created as a result of migration in the I column. Specifies how to migrate this pageview tag in the J column. Unless it is a tag for virtual pageview, it is better to use “Config Tag”, and for the tag for virtual pageview, it is better to use “Event Tag”. Also, if you do not want to migrate, select “Do Not Migrate”.

5.3. Listing field setting data

Select “GTM Migration > Pageview Migration > List UA Fields” on the menu bar. This will extract the field setting data of “Google Analytics” linked to the GA setting variable specified in 5.1.

The extracted field setup data will appear in columns L to P of the spreadsheet. From here, update the settings for the three columns N, O, and P.

5.4. Listing Custom Dimension Data

This will extract the custom dimension data of “Google Analytics” linked to the GA setting variable specified in 5.1.

The extracted custom dimension data will be displayed in the R-Y columns of the spreadsheet. From here, update the settings for the four columns V, W, X, and Y.

5.5. Run page view migration

Execute “GTM Migration > Pageview Migration > Migrate Config Tag” and “GTM Migration > Pageview Migration > Migrate Pageview Event Tags” on the menu bar to migrate pageview tags.

After the migration execution is completed, if you check Google Tag Manager, the GA4 setting tag and page view tag will be registered with the migration performed. These changes are registered in the workspace set in the sheet “GTM URL” and are not yet published, so please check the settings yourself and check the movement by previewing before publishing. .

6. Event migration

Event tags migrate as well as page views. The procedure is the same as “5. Page view migration”, so the details are omitted. The menu corresponds to “GTM Migration > Event Migration”, and while executing these one by one, let’s fill in the GA4 settings.

The following is the screen during setting and executing “GTM Migration > Event Migration > Migrate Event Tags”.

Depending on the site, there may be a large number of event tags, and in that case the execution time will be long, but let’s wait patiently. However, if the number is too large and timeout occurs, it may be necessary to divide and execute each event multiple times.

7. Check for changes in Google Tag Manager

It is the role of ” GA4 GTM Migration Tool ” to complete the execution of page view and event migration . After that, go to the management screen of Google Tag Manager, check the change history of Google Tag Manager, and check the detailed operation in the preview. This migration function only adds tags. If there is a problem, you can readjust it. to proceed).


This time, I introduced how to use the ” GA4 GTM Migration Tool ” published on Github . In the future, as the movement from UA to GA4 becomes more active, it will become necessary to migrate tag implementation to GA4. In such a case, if there is something like this migration tool, it will be possible to migrate quickly.

However, if you don’t understand the data model of GA4, you will end up not being able to set it correctly because you won’t know how to set it correctly. Instead, it should be recognized as “a tool for people who understand GA4 to some extent to migrate tags from UA to GA4 in a short time”.


Leave a reply

Please enter your comment!
Please enter your name here

Recent Posts

Popular Posts

Most Popular

Recent Comments