How to access a dataLayer variable in Google Tag Manager
Google Tag Manager for WordPress offers several so called Data Layer variables so that you can easily manage several use cases with you tags.
A typical use case is to exclude certain logged in users from being tracked in Google Analytics or to set some custom Analytics variables so that you can segment your data to see what logged in users are doing on your site compared to anonymous visitors.
You can access those data in Google Tag Manager using Data Layer variables.
- To do so, open Google Tag Manager and select the container of your website
- Select Variables on the left pane
- Scroll down to see the red New button in the “User-Defined Variables” section
- Click on it
- Select Data Layer Variable from the list:
- Enter the name of the variable you would like to access. You can read about the variable names of this plugin on that page:
- You may set a default value here as well depending on whether you need such a value
- Click the Save button and enter a descriptive name for the variable which you will see on the GTM UI while editing tags and triggers