As the name suggests this type of variable is used to lookup for the value that matches a given input pattern.
In the context of GTM, the lookup table variable determines whether or not there is an exact match with an input pattern and if there is an exact match then return the corresponding output value. If there is no exact match then return ‘undefined’ (unless the default value has been set).
By using lookup table variables you can greatly reduce the number of tags required to send hit data (esp. ‘event’ data) to Google Analytics.
A lookup table variable is made up of input variable and lookup table:
The lookup table is made up of one or more rows and two columns. You can add as many rows as you like to a lookup table. However, the number of columns in the lookup table will always remain two.
The first column of the lookup table is labelled ‘Input’ and is used to specify ‘Input Patterns’: For example:
You can use any string as an input pattern. You can also use any GTM variable as an input pattern. But you can not use regular expression as an input pattern.
The second column of the lookup table is labelled ‘Output’ and is used to specify ‘Output values’. For example:
From the screenshot above we can conclude the following:
If the output of the input variable matches the input pattern ‘start’ then set the output value to ‘video started playing’.
If the output of the input variable matches the input pattern ‘complete’ then set the output value to ‘video finished playing’.
The corresponding output value of the last matched pattern is the value returned by a lookup table variable. It is important to remember that this match needs to be an exact match and is case sensitive.
You can reference/call any GTM variable (including another lookup table variable) from within the output value field:
You can also reference the lookup table variable in custom HTML tags and custom JavaScript variables.
The input variable is the GTM variable (either built-in or user defined variable) whose output is checked against the input patterns you specify in the ‘Lookup Table’:
The output of the input variable is checked against each input pattern, row by row, from top to bottom in the lookup table.
When the output of an input variable last matches an input pattern, the corresponding output value of the last matched input pattern is resolved and then returned by the lookup table variable. If no match is found then the default value is returned.
If the default value has not been set and no exact match is found then the lookup table variable returns ‘undefined’.
In other words, the following are the possible outputs of the {{Video Status}} variable:
start
complete
pause
seek
buffering
progress
If you use {{Video Status}} variable as an input variable then its value will be checked against each input pattern, row by row, from top to bottom in the lookup table:
When the output of the {{Video Status}} input variable last matches an input pattern, the corresponding output value of the input pattern is resolved and then returned by the lookup table variable.
For example, let us suppose the output of the {{Video Status}} input variable at run-time was ‘complete’.
Now when the lookup table variable is referenced/called, the output of the {{Video Status}} input variable will match the input pattern ‘complete’ and the corresponding output value ‘video finished playing’ will be returned by the lookup table variable:
Another example, if the output of the input variable {{Video Status}} is ‘start’ at run time then it will match the ‘start’ input pattern.
And when the input variable matches the input pattern ‘start’ then the output value will be set to ‘video started playing’ and the lookup table variable ‘Video Player State’ would return the string ‘video started playing’:
Another example, if the output of the input variable {{Video Status}} is ‘pause’ at run time then it will not match any input pattern.
And when the input variable does not match any input pattern then the lookup table variable ‘Video Player State’ would return ‘undefined’ (unless a default value has been set):
Another example, consider the following lookup table:
If the output of the input variable {{Video Status}} is ‘start’ at run time then it will not match any input pattern including the input pattern ‘start playing’. This is because only the ‘exact match’ operation is carried out in the case of lookup tables and ‘start’ is not an exact match of ‘start playing’
And when the input variable does not match any input pattern then the lookup table variable ‘Video Player State’ would return ‘undefined’:
Another example, consider the following lookup table:
If the output of the input variable {{Video Status}} is ‘start’ at run time then it will match the last matched input pattern.
So the output value will be set to ‘video started’ and the lookup table variable ‘Video Player State’ would return the string ‘video started’:
Usually the input variable should return a single value at a time. But sometimes it can run multiple values. In that case, all of the values returned by the input variable should match one of the input patterns.
For example, consider the following custom JavaScript variable which returns an entire array:
Now if we use this custom Javascript variable as an input variable then the output of the input variable will return all of the following values at run time: start,complete,pause,seek,buffering,progress
So unless one of your input patterns is ‘start,complete,pause,seek,buffering,progress’, your lookup table variable will return ‘undefined’:
You can set a default value for your lookup table variable by clicking on the ‘Set Default Value’ checkbox and then entering the default value:
If you have set the default value to ‘no match’ then when the output of the input variable does not match any of the specified input patterns, the lookup table variable returns ‘no match’ instead of ‘undefined’.
It is important to note that if an input variable does not match any given input pattern then GTM will not throw any error or give you a warning message.
Another example, consider the following lookup table:
If the output of the input variable {{Video Status}} is ‘Start’ (note the word start with a capital letter) at run time then it will match the first input pattern and not the second. This is because the value lookup is always case sensitive.
So the output value will be set to ‘video started playing’ and the lookup table variable ‘Video Player State’ would return the string ‘video started playing’:
Step-1: Login to your GTM account and then click on the ‘Variables’ link in the left hand side menu:
Step-2: Scroll down to ‘User-Defined Variables’ section and then click on the ‘New’ button:
Step-3:Select ‘Lookup Table’ from the ‘Choose Variable Type’ menu
Step-4: Enter a name for your Lookup table variable. You will later reference the lookup table variable by this name.
Step-5: Select Input variable from the drop down menu:
If your input variable does not already exist then create a new one. You need an input variable in order to use a lookup table variable.
Step-6: Enter input pattern and its corresponding output value in the lookup table, row by row, from top to bottom:
Step-7: Specify the default value for your lookup table variable by clicking on the ‘Set Default Value’ checkbox and then entering the default value:
Here when the output of the input variable does not match any of the specified input patterns, the lookup table variable returns ‘no match’ instead of ‘undefined’.
Use Case for Lookup Table Variables
Lookup table variables are ideal for using one tag for sending different event hits.
"How to use Digital Analytics to generate floods of new Sales and Customers without spending years figuring everything out on your own."
Here’s what we’re going to cover in this training…
#1 Why digital analytics is the key to online business success.
#2 The number 1 reason why most marketers are not able to scale their advertising and maximize sales.
#3 Why Google and Facebook ads don’t work for most businesses & how to make them work.
#4 Why you won’t get any competitive advantage in the marketplace just by knowing Google Analytics.
#5 The number 1 reason why conversion optimization is not working for your business.
#6 How to advertise on any marketing platform for FREE with an unlimited budget.
#7 How to learn and master digital analytics and conversion optimization in record time.
My best selling books on Digital Analytics and Conversion Optimization
Maths and Stats for Web Analytics and Conversion Optimization
This expert guide will teach you how to leverage the knowledge of maths and statistics in order to accurately interpret data and take actions, which can quickly improve the bottom-line of your online business.
Master the Essentials of Email Marketing Analytics
This book focuses solely on the ‘analytics’ that power your email marketing optimization program and will help you dramatically reduce your cost per acquisition and increase marketing ROI by tracking the performance of the various KPIs and metrics used for email marketing.
Attribution Modelling in Google Analytics and BeyondSECOND EDITION OUT NOW!
Attribution modelling is the process of determining the most effective marketing channels for investment. This book has been written to help you implement attribution modelling. It will teach you how to leverage the knowledge of attribution modelling in order to allocate marketing budget and understand buying behaviour.
Attribution Modelling in Google Ads and Facebook
This book has been written to help you implement attribution modelling in Google Ads (Google AdWords) and Facebook. It will teach you, how to leverage the knowledge of attribution modelling in order to understand the customer purchasing journey and determine the most effective marketing channels for investment.
About the Author
Himanshu Sharma
Founder, OptimizeSmart.com
Over 15 years of experience in digital analytics and marketing
Author of four best-selling books on digital analytics and conversion optimization
Nominated for Digital Analytics Association Awards for Excellence
Runs one of the most popular blogs in the world on digital analytics
Consultant to countless small and big businesses over the decade
Get My Step-By-Step Blueprint For Finding The Best KPIs (32 pages ebook)
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.
This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
Cookie
Duration
Description
cookielawinfo-checkbox-analytics
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional
11 months
The cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy
11 months
The cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.