Use Lookup Table Variable in GTM

Using the Lookup Table variable in GTM comes very handily when output changes based on an Input defined by a certain logic. Let me show that to you by an example.

 Lookup Table Variable Example in GTM

Let us say that you maintain a very big website with multiple subdomains for different purposes. If the main website is then you have the following other subdomains for this website

  • for payment:
  • for Blog:
  • for landing page: and many more subdomains.

Now, you want to put Google Analytics tracking code on all of these websites at once. In that case, the Lookup table can be very handy. Create a lookup table variable in GTM and here is the logic. Before that let us have a look at the following example:

Lookup Table Variable in GTM

Lookup Table Variable in GTM

In the above picture, In the Input, we have different sub-domains as shown above. In the output, we will have different Google Analytics Tracking ID something like UA-xxxx-xx.

Near the top, you will see that there is something called Input variable. Then you will see a table with input and output. In the input, you can list out different inputs that the Input variable might take the form of.

Input variable example in a Lookup table:

In this case, the Input variable for the LookUp table is the URL hostname. A user might be on any page of the website from the above example and this page could be any page from any of the subdomains.

Now, based on the page hostname, which will be matched against the inputs that we have given, there will be output in the form of GA ID. At the bottom, there is also a default GA ID. So, let us say, currently, the user is on then the URL hostname, in this case, is  Now, this data will be sent to the Google Analytics through the UA-ID which was assigned for that particular subdomain.

If the above condition does not match then, the output will be the default output given at the bottom of the LookUp table. Look at the name of this LookUp table variable at the top. We are soon going to utilize this variable name.

Using Lookup Table variable name in GTM

Lookup Table Variable use in GTM

Now, let us say that you created an event on different subdomains and you want GTM to automatically send the event data to those Google Analytics accounts, then you simply use the Lookup table variable name in the tracking ID and based on the condition, the data will automatically go to the respective Google Analytics account.

This article shows some cool stuff that you can do with the lookup tables.

Have a Question? Get in Touch!

Leave a Reply

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