So product_id is already being populated int he datalayer? And you want an array in product_category to be generated to mirror the product_id, product_id : ["100", "200", "300", "200" ] product_cat: ["cat_a", "cat_b", "cat_c", "cat_b" ] using the lookup table will only work for one value and will not generate an array for you. You will probably need to create a JS extension to do this, with your own mapping table. So the quickesst solution would be to create your own mapping table, something like this, var map = {
key1: "v1",
key2: "v2",
key3: "v3",
key4: "v4",
key5: "v5",
key6: "v6",
key7: "v7",
key8: "v8"
} then create a JS function to loop through the keys to grab them and put them into an array, i have written something like this: var product_id = ["key2","key6","key3"]; //lets assume you are using product_id from the datalayer
//we are then going to loop through this productid array and grab the correct keys and values
var product_category = [];
var arrayLength = product_id.length;
for (var i = 0; i < arrayLength; i++) {
product_category.push(map[product_id[i]]);
}
and then here we will output the generated array which you will then push back into the datalayer
console.log(product_category); //you should see ["v2", "v6", "v3"]
This is just for deomnstation on how you can use JS extension to make your array for product category, you should be able to test this method in your console and see how it works... But you may need to adapt the map to accomodate your productid etc.. but this should be a good start for you in understanding how to generate a dynamic list array,
... View more