Articles on: Troubleshooting

Variables

What are Variables?




Variables in Google Tag Manager are named placeholders for values that are populated when code runs on your website. For example, the Tag Manager variable named 'Page URL' returns the current web page URL.

Variables are used in both triggers and tags:

In triggers, a variable is used to define filters that indicate when a particular tag should be fired.

Tags use variables to capture dynamic values (for example, pass a transaction value and product ID to a conversion tracking tag).


Google Tag Manager provides a set of predefined built-in variables. Built-in variables cover most tag and trigger configuration needs. You can also create user-defined variables for web pages to meet specific requirements that may not be covered by built-in variables.


How do you create a variable?





Within your web or server container you can go to 'Variables' in the left menu. Here you will always find a number of variables set by Google as standard. Under user-defined variables you can create variables yourself by clicking on the blue 'New' button.

Go to your server container.

Go to your variables.

Create a new variable.

As a variable configuration, choose what corresponds to what you want to pass. If you want a constant value such as your own Facebook pixel or access token, choose a constant variable. If you want to get something out of your data layer, choose an Event Data variable.

Under the Value, enter what you want to continue calling in this variable. Is that something from the data layer? Then view these steps below.



Event Data from data layer




Using a data layer checker plugin you can see on your site what data is stored and under which key it can be accessed.




For example, if you want to provide the event_id of a session, copy that key (not the value) from your data layer checker as you can see in the screenshot and enter it as Key Path.


Do you want to know which user-defined variables there are and what you can measure with them? Check out this article from Google.

Updated on: 06/09/2023

Updated on: 16/08/2024

Was this article helpful?

Share your feedback

Cancel

Thank you!