A Data Layer in simple programming terms is an object created to store values, these values are like attributes for a defined variable for e.g.

How to access values in a Data Layer:

To access a value in a Data Layer, you need to just go through a few steps:

  1. Go to your Google Tag Manager account
  2. Click on the GTM Container
  3. Click on ‘Variable’ and then click on ‘New’
  4. From the list of variables, select ‘DataLayer Variable’
  5. Give a name to the DataLayer Variable and in the value field, write the name of the ‘Data Layer Variable’ you want to call and save

You will see an option for version 1 and version 2

  • Version 1 is not usually used because it does not allow you to access nested values
  • Version 2 can access any variable available in the DataLayer and its value

By default, the value output type is a string

If you want to use the value of the variable in any other tag or script, you can just use {{test}} to call the value of the DataLayer variable.

I hope this tutorial helps you in tracking and adding new Data Layer variables to your object to gather more insights on your visitors. Don’t forget to comment below to let me know what do you think about this post.

Leave a comment

Your email address will not be published.