Lookup table variables are used like a javascript switch, and are often used in GTM for multiple situations. For example, if you want to make a data collection for a limited number of elements, but some information is not available, you can tell which information should be there for each element. In this case, using a lookup table variable will help you.


Common Uses of Lookup Tables

A useful scenario when lookup tables come to rescue is if the same tracking will be used on multiple domains, and the only change needed is the GA Account ID. In this case, you can create a lookup table variable with the Input Variable: Page Host, and for every domain, you can add an output value for the specific GA Account ID.


A less common scenario (due to limitations and hard coding), is to take some information about specific elements and return other information for each element. For example, let’s say you have 5 main categories on your site. You have the name of category, but you need the ID of it. In this case, you can make a lookup table, and for each name you can type the correct ID.


How to Implement Lookup Tables in GTM

Implementing a lookup table variable in GTM can be simple if you follow these steps. First, you will add a new User Defined Variable and select the lookup table type. After that, an Input Variable is needed. This variable is used to collect the available information that will be changed by the lookup table.


Lookup Tables and Data Quality


The lookup table will transform the input taken from the Input Variable and return a new value that is chosen by the engineer. After selecting the Input Variable, you add rows and introduce which value will have that variable, and decide what value you want to return. You can also include a Default Value in case the input value is different or the Input Variable is not defined.


Lookup Tables and Data Quality


Compact Tracking Using Lookup Tables

Let’s say you have multiple tags with different triggers, but the only change on those tags are the Event Actions and/or Event Labels. By using the lookup tables, you can create only one tag instead of one tag for every different Event Action and/or Event Label.

How can you do that? When you are creating the tag, instead of introducing hardcoded text in the Event Action input, you can use a Lookup Table Variable. Depending on what your Input Value is, you can return exactly what is your desired Event Action for every case.


Lookup Tables and Data Quality


In the previous image, I used the Click Text as the Input Variable. Depending on the text element, this variable will return the specific Event Action that I want. You can use the same thing for Event Label.


Instead of creating a lot of tags and triggers, you will create one tag with as many triggers you want and a Lookup Table Variable.


How It All Connects: Lookup Tables & Data Quality

Data quality is very important, and every analytics engineer knows that the actual result of his or her work will be seen on the reports. The quality of the work from the engineer is determined by the quality of the data. Messy data is the same as having no data. If data quality is poor, then it can not be trusted.


Properly usage of the Lookup Table Variables can help in this way. Even if you are using those for multiple domain tracking, only for some specific elements, or to make your tracking more compact, the quality can be affected.


Lookup Table Variables come to the rescue in multiple situations, and every analytics engineer that is using GTM has faced some situations where those variables are the answer.

About the author

Alex Holhos

Alex is a digital analytics engineer and Google Tag Manager subject matter expert with years of experience in web development and web analytics.

eBook: Understand Your Customers

Cognetik eBook: Guide to User Journey Analysis


Related Articles