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:

  • Content Grouping in Google Analytics
    Analyzing the contents of a website, has it ever happened to you that you want to know what are the performances of the main sections? Each website is divided into sections, which reflect the organization of its contents. This applies to all sites, from e-commerce, which have sections of product categories, type of articles, sellout […]
  • 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 […]
  • What Virtual Pages are in Google Analytics
    Pageviews are one of the best known metrics, present in almost all web analytics reports. This metric is populated with pageview hits, which are sent to Google Analytics every time we view a page or refresh the page itself. However, in recent years a series of technologies have developed that improve user navigation on the […]
  • How to track Virtual Pages: Google Tag Manager and Google Analytics
    In this post, we see how to track Virtual Pages with the help of Google Tag Manager and Google Analytics. If you don’t know what Virtual Pages are and learn more about how they can help you especially if you are tracking a Single Page Application, I suggest you to read my dedicated post. To […]
  • Google Analytics 4: Cross Domain Tracking
    In this post I’ll show you how to implement cross domain tracking in the new version of Google Analytics 4. With GA4 cross domain tracking is much easier than the Universal Analytics version, in fact: in Universal Analytics you had to set everything up within Google Tag Manager In Google Analytics 4 you can do […]
  • Google Analytics 4: Referral Exclusion List
    Referral traffic is, generally, traffic from other websites that contain one or more links to your site. The new Google Analytics 4 allows you to measure this kind of traffic for your analysis, without the use of tags, triggers or variables. Proper implementation of referral traffic allows you to understand which other websites are bringing […]
  • Google Analytics 4 Demo Account
    Google has just released the Demo Account for Google Analytics 4 Now, all users can access and discover the functionalities offered by GA4. But let’s go in order! Post Content: 1) What is the Google Analytics 4 Demo Account 2) How the Demo Account is implemented 3) What can I do with the Demo Account […]
  • Form tracking in Google Analytics 4
    In this post, I’m going to show you how to track a Form with Google Analytics 4 and Google Tag Manager. If you want to track the Lead of a user who fills out the Form on your website, firstly you must have created a new Property for GA4 and secondly created a tag in […]
  • PII (Personally Identifiable Information): what is it?
    You have often come across the acronym PII or Personally Identifiable Information and wondered what it is and how to fix it in Google Analytics. PII are all the information that can give you the possibility to identify a user. This topic is closely linked with Privacy and, especially for the EU, with the GDPR […]

Lascia un commento

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *