0

Hi please how would you set the variable to get the list of all skus purchased which are in an array in the data layer? For example:

transactionProducts:[

{sku: “1234”, name: “product 1”, price: “2.99”, quantity: “1”}
{sku: “5678”, name: “product 2”, price: “5.99”, quantity: “1”}
{sku: “9012”, name: “product 3”, price: “8.49”, quantity: “2”}

]

From the above array, I would want to get each sku value and have it return together as the value of the variable. So something like '1234', '5678', '9012'

Because now I make variable transactionProducts.0.sku but its only one.

Is there any way to do that? Thank you

Adam Gl
  • 3
  • 1
  • 3

1 Answers1

0

If you want to use a custom JS in GTM:

function () {
sku = []
for (i=0; i< transactionProducts.length; i++) { 
    sku.push(transactionProducts.i.sku); 
   }
return sku;
}
F. Leone
  • 594
  • 3
  • 14