arrays - Google Tag Manager > dataLayer variable find and replace with javascript variable -
i'm having trouble google tag manager datalayer variable not contain right information.
the "sku" field not named correctly , need change "variant". i'm trying achieve custom javascript variable in gtm whatever i'm trying i'm not able find , replace "sku" "variant" in products array.
all appreciated.
many in advance, adriaan
you can create custom javascript variable uses old array , replaces product parameters, that:
var arr = {{yourproductarray}}; //check if valid array arr.foreach(function(prod, index, array){ if(prod.sku) { arr[index].variant = prod.sku; arr[index].sku = ""; //reset value if needed } }); return arr;
Comments
Post a Comment