google-tag-managergoogle-datalayer

Is there a way to create a dataLayer variable in GTM, pointing to a nested object?


Is there a way to create a dataLayer variable in GTM, pointing to a nested object?

I've tried to have eventModel.items[0].name, but it returns as undefined even if eventModel.items is an array with a correct object inside.

I'm using Version 2 for this variable. Is there a specific syntax/way to access something nested in an array that deep?


Solution

  • I just had to use:

    eventModel.items.0.name
    

    Instead of:

    eventModel.items[0].name
    

    in my Data Layer variable.