Search for the Article

Access Array Members In The Data Layer

If you have a datalayer like the one below and you want to access datalayer variable that will return an array of IDs, Then I will explain how you might achieve that.

 




In JavaScript, we can access this with the following syntax.


inputs[0].value

Unfortunately, this line of code won't work in GTM. To make the code work in GTM, just replace the [0] with .0.

So, it would become


inputs.0.value

Hope this helps, if you need help in doing this , drop me an email..