English Posts

Google Tag Manager: Lookup Table Variable

lookup table variable google tag manager

The Lookup Table variable in Google Tag Manager allows you to read the value of an input and, if this value matches certain requirements, it will return some output.

There are several situations where this variable can help us: rename a web page, rename the Source dimension for a social (Instagram, Facebook LinkedIn etc.) and so on.

In this post I’ll show you how to use this variable, when we have two or more identical websites that have their own Google Analytics Property:

lookup table variable google tag manager

In such a situation, we can:

  1. Use a single Google Tag Manager container and triple all tags for each property (1, 2 and 3);
  2. Create three Google Tag Manager containers;
  3. Use a single container, without tripling the tags, and use the Lookup table Variable

Option number 3. is the best because it saves a lot of time and, above all, reduces the errors that can result from duplication.

Contents of the article:
- Create the Lookup Table Variable for Multiple Websites
- Insert the Variable in the Tag of GA4
- Insert the Variable in the GA Universal Analytics Tag

Create the Lookup Table Variable for Multiple Websites

At this point we can create the variable, going to Variables> New (User-Defined Variables):

user defined variable google tag manager

Then we select the Lookup Table Variable:

select the lookup table variable

At this point we have to:

  1. select the Input Variable: we have to choose the parameter (eg: Page Hostname) on which to base the choice whether to send the information to Property 1, 2 or 3 of Google Analytics;
  2. select the number of Outputs: indicate the Property ID or the Google Analytics 4 Measurement ID for each website;
  3. select the type of Input: indicate the value according to point 1.: if I choose the Page Hostname I must indicate the domain of the website:
lookup table input e output

Important: when we use this variable, we have to know that the value typed in point 3. is considered as an “exact match”. This means that, if I have a sub-domain (eg: blog.example.com), in the input I have to write the sub-domain for it, to be read correctly. If you entered example.com, the blog.example.com subdomain would not be read.

Another important thing to remember: if I select {{Page Hostname}} in point 1. it is not necessary to write ‘https’ in point 3. also. You can see it simply by activating the GTM Preview to observe which is the value that is collected, as in the example below:

page hostname variable

Insert the Variable in the Tag of GA4

Once we have created the Lookup Table variable, we need to modify the Google Analytics 4 configuration tag, so that information on user interactions on the website is dynamically sent to the different Properties of each website.

We enter the GA4 tag that interests us and click on the brick 1).

A list will appear, so we select the Lookup variable we created earlier and insert it.

google analytics 4 variable gtm

Each tag that refers to Google Analytics 4 must have this variable.

In this way:

  • the user’s action on the website sends an event to the data layer
  • the event is read by GTM and activates the tag
  • the information is sent to the various Properties created in GA4, based on the value of the {{Page Hostname}} variable

Let’s save the tag.

Insert the Variable in the GA Universal Analytics Tag

The same work can also be done if we were working on the Universal Analytics Property.

We will need to create the Lookup variable, as in the steps above.

The only thing that will change will be the Property ID, i.e. the tracking ID to be entered, which we find in the Property under Admin> Property Settings

tracking id universal analytics

This ID will be copied and output to the Lookup Table variable:

lookup table universal analytics

Next, we’ll need to go inside the tag that sends the information to Universal Analytics and:

  1. Click on Enable overriding settings in this tag
  2. Click on the brick to select the Lookup Table variable created earlier
lookup table variable in universal analytics

Then save, test everything and publish the new changes in the container.

Good analysis!


You might also be interested in the following articles:

  • Google Analytics 4: source/medium report
    One of the most popular reports within the Universal Analytics version is definitely the Source/Medium Report. In this Report, you can quickly observe the source and medium of users landing on the website. In UA we can find it under Acquisition > All Traffic > Source/Medium The new version of GA4 offers many features but […]
  • Landing Pages Report in GA4
    One of the most interesting reports in Google Analytics – Universal Analytics is the Landing Pages Report. In this report you can observe the first landing page of a user on the analyzed website. It’s a very useful report to quickly understand what our user’s entry points are. However, the question may arise: how do […]
  • Google Analytics 4: Comparison
    In this post, I’ll show you how to compare data in Google Analytics 4. Just as with the UA (Universal Analytics) version, where you can use segments to better analyze your users’ behavior on the site, GA4 offers a similar feature. However, there are some nuances, compared to the UA version. Compare data in GA4 […]
  • Search Console and Google Analytics 4
    In this post I will show you two things that I find very useful: Connect the Google Search Console directly to your Google Analytics Property 4 Save a widget for faster access to Search Console data in the GA4 User Interface Let’s start! How to Link Search Console to GA4 Property The steps to link […]
  • How to Change Language in Google Data Studio
    Google Data Studio is a great data visualization tool that is completely free, allowing you to connect different data sources to create dashboards. Some of the available data sources are: Google Analytics Google Sheets Google BigQuery File in .csv etc. The sources are different and, as you have seen, they are not only from the […]
  • How to Implement Content Group in Google Analytics 4
    Content Groups allow you to create sections of the website, grouping contents in a convenient way for your analysis. Let’s give some examples: I can create a specific group that shows me the most viewed Brands on my website or I can create Product categories to analyze, at a higher level, the interactions of users […]
  • Server-side Tagging: what is it?
    Update: October 5th. Google Tag Manager Server Side is officially out of Beta, as confirmed by Google, and has entered a new phase. Announced in August 2020, Google Tag Manager Server-side is still a tool / theme unknown to most. There are many doubts and questions on the subject and in this post I want […]
  • Content Grouping in Google Analytics
    Note: this article refers to the Universal Analytics version. If you want to know how to implement Content Groups in GA4 via Google Tag Manager, you can read this blog post. Analyzing the contents of a website, has it ever happened to you that you want to know what are the performances of the main […]
  • Google Tag Manager: Lookup Table Variable
    The Lookup Table variable in Google Tag Manager allows you to read the value of an input and, if this value matches certain requirements, it will return some output. There are several situations where this variable can help us: rename a web page, rename the Source dimension for a social (Instagram, Facebook LinkedIn etc.) and […]

Lascia un commento

Il tuo indirizzo email non sarà pubblicato.