On this page
In plain English
Pushing information to the data layer is only half the job. A data layer variable is how GTM picks a value out so you can use it in tags and triggers.
Create one by choosing the Data Layer Variable type and entering the key name exactly as it appears in the data layer. Names are case-sensitive. For nested values use dots, for example ecommerce.value.
If the value shows as undefined in Preview mode, the key name usually doesn't match, or the value was pushed after the tag fired.
Example
The data layer contains form_name: 'contact'. A data layer variable with the name form_name returns contact, which you can send to GA4 as an event parameter.
Official documentation
- User-defined variable types for web (opens in a new tab) Tag Manager Help
- The data layer (opens in a new tab) Google for Developers
Last reviewed