我们已经在网站上实施了Google Analytics(分析)电子商务跟踪。我们注意到,Google Analytics(分析)缺少一些交易。只有一些数据丢失,而其他事务则被正确记录。
对于丢失的订单没有具体的模式(例如,所选产品,使用的设备...等)。
以下是将交易数据推送到分析的代码段。
var products = [];
for (i = 0; i < cart.lines.length; i++) {
var cartItem = cart.lines[i];
if (cartItem != null && cartItem != 'undefined') {
products.push({
'name': cartItem.cartProduct.name + ' ($' + cartItem.cost + ')',
'id': cartItem.cartProduct.id ,
'price': cartItem.cost,
'brand': 'My Brand XXX',
'category': cartItem.category,
'variant': 'My Brand XXX',
'quantity': 1 // Iterating item by item therefore hardcoding quantity to 1
});
}
}
// Pushing ecommerce transaction data to data layer
window.dataLayer = window.dataLayer || [];
dataLayer.push({
'ecommerce': {
'purchase': {
'actionField': {
'id': cart.referenceNumber, // Transaction ID. Required for purchases and refunds.
'affiliation': store.name,
'revenue': cart.totalPrice, // Total transaction value (incl. tax and shipping)
'tax': 0,
'shipping': cart.deliveryCharge,
'coupon': ''
},
'products': products
}
},
'event': 'purchase'
});
}
请注意,我可以访问完全填充的“购物车”和“商店”对象。
赞赏是否有人可以帮助您弄清楚是什么原因造成的。
最佳答案
好吧,您的代码看起来不错。没有任何具体方法可以确定导致此问题的原因。
您可以在上述特定代码中实施异常跟踪,这样您将了解导致问题的可能原因。
要使用GTM实施异常跟踪,您需要将以上代码包装在try catch块中,并在catch块中推送带有异常详细信息的datalayer事件。在GTM的另一侧,配置异常跟踪标记。
希望这会帮助你。如果需要实施异常跟踪的任何帮助,请告诉我。
关于google-analytics - Google Analytics(分析)-GA中未显示某些电子商务交易,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34734295/