我正在尝试在adobe标签管理器中获取SKU的值。这是电子商务网站吐出的代码块:
digitalData.ecommerce.event = eventType;
digitalData.ecommerce.step = stepCount;
digitalData.ecommerce.transactionId = "CA181119-04865001";
digitalData.ecommerce.transactionTotal = "1159.98";
digitalData.ecommerce.transactionTax = "0.0";
digitalData.ecommerce.customerId = "";
digitalData.ecommerce.customerCity = "";
digitalData.ecommerce.customerZip = "";
digitalData.ecommerce.customerBirth = "";
digitalData.ecommerce.customerGender = "";
digitalData.ecommerce.transactionShipping = shippingVal;
digitalData.ecommerce.transactionDiscount = discountVal;
var transactionProds = {
"sku": "SM-T280NZKAXAC",
"name": "Galaxy Tab A (7.0)",
"category": "",
"price": "199.99",
"quantity": "1",
"discount": "0.0"
};
digitalData.ecommerce.transactionProducts.transactionProds;
var transactionProds = {
"sku": "SM-G955WZKAXAC",
"name": "Galaxy S8+",
"category": "",
"price": "959.99",
"quantity": "1",
"discount": "0.0"
};
我尝试了这段代码,但是没有用:
var noOfproducts = [];
var SKU = "";
for (var i = 0; i < noOfproducts.length; i++) {
SKU += digitalData.ecommerce.transactionProducts[i].sku + "<br />";
}
有人可以告诉我如何编写适当的脚本以从原始代码中获取SKU的所有值吗?
答案 0 :(得分:0)
实际上我想通了,用了这个:
sku = []
for (i=0; i< digitalData.ecommerce.transactionProducts.length; i++) {
sku.push(digitalData.ecommerce.transactionProducts[i].sku);
}
return sku