I'm trying to reference a dataLayer variable in a custom html tag in GTM that is part of a product array, but my supplier has informed me that the variable keeps returning as "undefined". In the tag I defined the variable as {{transactionProducts.category}}
I have checked the macros in debugger and I think I can see the problem - it looks like this variable is defined both as a single dataLayer variable which is where it comes up as undefined, and then again as an array under transactionProducts, along with other parameters that we have defined i.e. sku, name, category, price and quantity.
These macros are pulling through correctly - so these are the ones that I want, not the single undefined macros.
My question is - how do I access these? I thought to access the array it should be defined using "." i.e. transactionProduct.category - but this is defaulting to the single undefined macro...
Any thoughts anyone?
Apologies if this is a super simple question - I'm still getting to grips with things.
Cheers,
Rosie
I spent hours to find solution (that's how I found your question) :)
So, the solution: 1. Create new Variable with Data Layer Variable Name transactionProducts.category name it, for example, transactionProducts_category
2 Use {{transactionProducts_category}} instead of {{transactionProducts.category}}
ps. I used DL Variable Version 2