Tutorial: Using Lookup Table Variable in GTM for Data Cleaning

Photo of a group of MarTech developers taken from above, as they work on laptops to enhance their digital data cleanliness with the GTM Lookup Table Variable.

Introduction 

Welcome to our tutorial on leveraging the Lookup Table Variable in Google Tag Manager (GTM) for effective data cleaning. As mentioned in many of our other publications, we cannot emphasize enough the pivotal role of accurate digital data in informed decision-making. In this tutorial, we’ll dive into the power of the Lookup Table Variable within GTM, demonstrating how it can enhance your data management capabilities. 

What is a Lookup Table Variable? 

Before we get into the technical aspects, let’s take a moment to understand what makes the Lookup Table Variable a valuable asset in your data cleaning arsenal.

Essentially, it functions as a dynamic tool that outputs a value based on a specified input. Think of it as a virtual spreadsheet where you define inputs and their corresponding outputs. This functionality is particularly advantageous for data cleaning tasks such as standardizing naming conventions, transforming values, or rectifying common data entry errors. 

Photo of a hand holding a phone, as the user is shopping on an ecommerce site with the words overlaid Mastering Digital Marketing: the art and science of Retargeting

Step-by-Step Guide 

Step 1: Access Google Tag Manager 

Begin by logging into your Google Tag Manager account and selecting the appropriate container for your website. 

Step 2: Create a New Variable 

Navigate to the GTM Dashboard, click Variables in the left menu, and create a new variable.  

Choose Lookup Table as the variable type. 

Step 3: Configure the Lookup Table 

Define your input variable and set up your input-to-output mapping. This involves specifying the values you wish to clean or transform and their respective replacements. Add as many rows as necessary to meet your data cleaning requirements. 

Input Variable

Select the variable that will be your input. For instance, this could be a page URL, event name, or any other variable you want to clean or transform. 

Table Rows

Here, you will define your input-to-output mapping. 

Input

Enter the value you expect (for example, a common misspelling or a raw event name). 

Output

Enter the value you want to replace it with (for example, the corrected spelling or a standardized event name). 

 Step 4: Set a Default Value (Optional) 

Consider setting a default value to catch unexpected inputs that don’t meet specified conditions. 

This is useful for catching unexpected values. 

Step 5: Name and Save Your Variable 

Give your variable a descriptive name that reflects its purpose, such as Cleaned Event Names or Standardized URLs.

 Step 6: Test Your Variable 

Implement the variable in tags or triggers where needed.  

Utilize GTM’s Preview mode to ensure the variable functions as expected. You should be able to validate if the inputs are correctly being transformed into the desired outputs. 

Step 7: Publish Your Changes 

Once you’re satisfied with the setup, click Submit to publish your changes. 

Use Cases for Data Cleaning 

  • Standardizing Query Parameters: Ensure consistent tracking by cleaning and standardizing URL query parameters. 
  • Correcting Misspellings: Automatically rectify common misspellings in event names or other text strings. 
  • Transforming Values: Convert values, such as changing “yes”/”no” to “true”/”false.” 
  • Categorizing Values: Group input values into broader categories for simplified analysis. 

 Tips for Effective Use 

  • Regularly Update: Keep your lookup table current with new findings or changes in your data structure. 
  • Use with Other Variables: Combine lookup tables with other GTM variables for more complex data transformations. 
  • Document Your Tables: Maintain a detailed record of why and how each lookup table is set up for future reference. 

Conclusion: Lookup Table Variables are a powerful tool for data cleaning 

In conclusion, Lookup Table Variables in Google Tag Manager are a versatile and powerful tool for data cleaning. By standardizing and correcting data at its source, you pave the way for more accurate and reliable data collection, ultimately leading to better insights and decision-making.  

We should note – there are options available in case you need to check for a regex pattern instead of static values… but that’s a topic for another day. Check back soon! 

If you have any questions or need further guidance, don’t hesitate to reach out to Project 3 Consulting. Your success is our priority. 

Photo of a MarTech consultant providing implementation tips with a prompt written to the side "Want more implementation tips like these?" and a link to connect with Project 3 Consulting

Love Bytes: a MarTech Match Made in Heaven

Ah, love and marketing technology – two seemingly unrelated topics that, when brought together, can create a symphony of data-driven romanticism. In the spirit of Valentine's Day, let's explore the idea that good data is not the destination, it's the starting line....

read more