GTM数组返回[object Object]而不是产品

时间:2018-09-05 13:00:02

标签: javascript arrays

因此,我尝试将一系列产品传递给GTM标签,当我进行调试时,我可以看到自定义变量正确填充,但是当我调试标签本身时,该变量仅返回[object Object],[对象对象]等...

我正在使用的代码如下,感谢任何帮助/指针!

function() {
var dlv = function(key){ return google_tag_manager[{{Container ID}}].dataLayer.get(key)};
var productArray = [];
    for (i=0; i < dlv("transactionProducts").length; i++) {
        var pO = {};
        pO.quantity = dlv("transactionProducts")[i].quantity;
        pO.unitPriceLessTax = dlv("transactionProducts")[i].price;
        pO.SKU = dlv("transactionProducts")[i].sku;
        pO.productName = dlv("transactionProducts")[i].name;
        productArray.push(pO);
    };
return productArray;

}

该变量名为{{dataLayerProductsPurchased}}

标记脚本:

orderid : "{{dataLayerTransactionID}}",
currency: "{{dataLayerTransactionCurrency}}",
customerStatus: "",
conversionType: "{{dataLayerTransactionType}}",
customerID: "",
discountCode: "{{dataLayerPromoCode}}",
discountAmount: "0",
taxAmount: "{{dataLayerTransactionTax}}",
lineitems : "{{dataLayerProductsPurchased}}"

0 个答案:

没有答案