I'm attempting to establish a dataLayer variable in order to push the product name into the event label.
Here is the dataLayer push that occurs when a user adds a product to their cart:
{
event: "addToCart",
gtm: {
uniqueEventId: 107,
start: 1666871102469,
scrollThreshold: 75,
scrollUnits: "percent",
scrollDirection: "vertical",
triggers: "30151582_46"
},
customer_id: "4cfa14bf-1749-47a3-9063-e19c0bc6f3a8",
ecommerce: {
currencyCode: "NZD",
add: {
products: [
{
name: "Panadol Rapid Soluble Tablets - Packet 20",
id: "FAH262",
price: 12.28,
brand: "Panadol",
category: "Web / Dental / Consumables / Anaesthetics / Pain" +
" Relief",
variant: "",
quantity: 1
}
]
}
}
}
I have attempted to create a dataLayer variable using:
ecommerce.add.products[0].name
However, in preview mode, this is returning as undefined when I test adding items to the cart.
Where might my mistake be in this setup?