I am trying to understand how Google Tag Manager matches variables to fields in the objects pushed to the dataLayer. When it's a top level field, it is straightforward. However, how does one do matching when I want to push something like this:
dataLayer.push({
'subcontainer': {
'variable': true
}
}
Would I match subcontainer.variable (which seems like the obvious way)? I couldn't find documentation for this, maybe someone could point me to something that explains this.
You would have to create a dataLayer variable its value would be subcontainer.variable and version would be 2 in version 2 dots(.) access nested values. Values pushed to the Data Layer with dots in the name will be interpreted as nesting values according to normal JavaScript rules.
You can find more about it here https://support.google.com/tagmanager/answer/6106899?rd=1#web