Skip to content

How to Use the GTM Variable Library

This guide walks you through setting up the ggLowCodeGTMKit variables in Google Tag Manager, demonstrating how to install them and how to leverage their powerful chaining capabilities.

You will learn how to import the variables into your GTM container and how to use them in different scenarios:

  • Scenario 1: Cleaning a price extracted from the DOM and transforming it into a number.
  • Scenario 2: Taking a list of 3 items and joining their IDs into a single string.
  • Scenario 3: Calculating the total value of 3 items in a shopping cart.

After these scenarios, you should feel confident using the variables in your own projects, with a strong understanding of both Direct Mode and Apply Mode.

Before we begin, download the How-To Examples container that includes all the variables and mock data used in this guide:

πŸ“¦ Download ggLowCodeGTMKit_HowTo_Examples.json

This container includes mock data sources and a selection of pre-configured variables so you can follow along step-by-step.


To add the variables to your GTM container, we will use the built-in import feature.

  1. Navigate to Admin in your Google Tag Manager workspace. ![](/images/howto/Screenshot 2026-05-04 at 00.54.11.png)

  2. In the Container column, click on Import container.

  3. Click Choose File and select the ggLowCodeGTMKit_HowTo_Examples.json file you downloaded earlier. Select Overwrite or Merge, then click Add to Workspace.

  4. Go to Templates. You should see the 7 templates imported. This is where the template definitions live, but the actual variables are not created in the workspace yet.

    • (Mock) Ecommerce Items: Creates mock data for ecommerce items (represents an item list available in a datalayer).
    • (Mock) Raw DOM Price: Simulates a dirty price value extracted from a DOM element.
    • clamp(…): Library variable used to clamp a number within a specified range.
    • itemPluckProperty: Library variable used to pluck a property from an array of items.
    • join(…): Library variable used to join an array of strings into a single string.
    • parseCurrency: Library variable used to parse a currency string into a number.
    • sumProductOfProperties: Library variable used to sum the product of two properties (e.g., price Γ— quantity) across items.

    Note: Outside of the mocked variables, these library templates use two naming nomenclatures depending on how they are meant to be used. Direct Variables have no suffix, while variables designed to be chained in Apply Mode include () or (...) as a suffix.

  5. Go to Variables, then click New. Import the mock variables and name them as you wish (using the template name is a great way to begin).

    Import Mock 1
    Import Mock 2
    Import Mock 3
    Import Mock 4

    You can verify the values using Preview mode. You can launch the preview mode from this page: www.youdontknowga.com/playground/gtm by entering your GTM ID. The debugger will open in a new window allowing you to inspect the variable values in the left panel.


We will work on three standard scenarios in parallel to demonstrate how to use the variables.

Create a new variable using the parseCurrency template, passing (Mock) Raw DOM Price as the input parameter. Proposed name: ProductPrice Β§ Parsed

Create a new variable using the itemPluckProperty template. Pass (Mock) Ecommerce Items as the first parameter, and type item_id as the property to pluck. Proposed name: ItemIds Β§ Array

Create a new variable using the sumProductOfProperties template. Pass (Mock) Ecommerce Items as the first parameter, price as the second, and quantity as the third parameter. Proposed name: ItemsTotalValue

Go to Preview mode to check the values of the variables. As you can see:

  • The product price is β€œluckily” well parsed.
  • The list of item IDs is well extracted, but it’s currently an Array, and we would prefer it to be a string of comma-separated values.
  • The total cart value is perfectly calculated.

We will now use Apply Mode to demonstrate how to chain variables together and improve the final output.

We will import a new variable using the join(...) template, and add a comma , as the separator. Proposed name: join()

Next, open the ItemIds Β§ Array variable you created earlier. Instead of using it directly, switch its execution mode to Apply Mode, and select your new join() variable as the result output. Rename the variable to ItemIds Β§ String. The join() function will now be applied automatically to the output of the array extraction! Click Save.

We will add a safeguard to limit the risk of skewed data from our scraped DOM price, ensuring it stays within a defined minimum and maximum range. Import the clamp(...) template, and choose 1 and 10000 as the min and max values. Proposed name: clamp(1, 10000)

Then, open your ProductPrice Β§ Parsed variable, set it to Apply Mode, and attach the clamp(1, 10000) variable as the result output.

We can now go back into Preview mode and see that the data is much safer and better processed!

  • The Item IDs list is now a clean, comma-separated string.
  • The product price remains unmodified because it was within the valid [1, 10000] range, but the variable is now perfectly protected. (For example, if the scraped price was accidentally 999999, it would be safely capped at 10000).