i want to pull data from my datalayer in a Magento store, and store it as a variable in Google tag manager. I use the Welt pixel for creating data layer for the e-commerce data.
How can I put e.g. products.brand in a variable, so I can send it as a parameter in Google analytics 4.
I've tried to put in the following, in a variable - but non of them are right; ecommce.detail.products.brand, e-commerce.brand, products.brand
If I just put e-commerce, the whole array is being inserted as a variable.
Can anyone help me figuring this out?
{
ecommerce: {
detail: {
products: [
{
name: " Pinot Noir, Gaul",
id: "5704",
price: "150.00",
brand: "Matthias Gaul, Pfalz",
category: "Shoppen/Vine"
}
]
},
currencyCode: "DKK",
add: {
products: [
{
name: " Pinot Noir, Gaul",
id: "5704",
price: "150.00",
brand: "Matthias Gaul, Pfalz",
category: "Shoppen/Vine",
list: "Shoppen/Vine",
quantity: "6"
}
]
}
},
It has to do with the data layer having two products
items; both having brand
key/value pairs. You will have to specify through an index value, which one to pull.
Something along the lines of ecommerce.detail.products.0.brand
if you are interested in the first products
. Zero indexing is in play with the first item being represented by 0 instead of 1.
Here is an article by AnalyticsMania that explains it in more depth.