gpt4 book ai didi

javascript - Google Analytics 电子商务跟踪无法正常工作 - 使用analytics.js

转载 作者:行者123 更新时间:2023-11-28 08:00:41 25 4
gpt4 key购买 nike

我们已在付款成功页面中添加了以下代码,但我仍然没有在分析中看到任何跟踪;有人可以帮忙吗?

  <script type="text/javascript">
(function(i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function() {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date(); a = s.createElement(o),
m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; m.parentNode.insertBefore(a, m)
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');

//Add Console log like below
console.log("Entering the Analytics code tracking");

ga('require', 'ecommerce', 'ecommerce.js');
//Add Console log like below
console.log("Loaded ecommerce.js");

ga('create', 'UA-XXXXXXX-X', 'auto');
ga('send', 'pageview');

//Add Console log like below
console.log("Adding Transaction");

ga('ecommerce:addTransaction', {
'id': '<%=intNewOrdrID%>', // Transaction ID. Required.
'affiliation': 'OTG', // Affiliation or store name.
'revenue': '<%=strGrandTotal%>', // Grand Total.
'shipping': '<%=strShipping%>', // Shipping.
'tax': '<%=strTax%>' // Tax.
});

<%for (int i = 0; i < dtOrderDetails.Rows.Count; i++)
{%>
ga('ecommerce:addItem', {
'id': '<%=intNewOrdrID%>', // Transaction ID. Required.
'name': '<%=dtOrderDetails.Rows[i]["ProductName"].ParseString().Replace("'", "\\'")%>', // Product name. Required.
'sku': '<%=dtOrderDetails.Rows[i]["SKU"].ParseString()%>', // SKU/code.
'category': 'OTG Product', // Category or variation.
'price': '<%=dtOrderDetails.Rows[i]["DiscountedPrice"].ParseString()%>', // Unit price.
'quantity': '<%=dtOrderDetails.Rows[i]["Quantity"].ParseString()%>' // Quantity.
});
<%}%>

//Add Console log like below
console.log("About to send transaction details");
ga('ecommerce:send');
</script>

我已经检查了几乎所有内容,但没有想法;有人可以扫描并检查吗?谢谢,-开发

最佳答案

我认为您将其与所有 <%=intNewOrdrID%> 混淆了。例如,清理数量应该是一个数字,而不是 <%=dtOrderDetails.Rows[i]["Quantity"].ParseString()%>

 ga('ecommerce:addTransaction', {
'id': '1408689736', // Transaction ID. Required.
'affiliation': 'Item Data Send Test', // Affiliation or store name.
'revenue': '11.99', // Grand Total.
'shipping': '5', // Shipping.
'tax': '1.29' // Tax.
});
ga('ecommerce:addItem', {
'id': '1408689736', // Transaction ID. Required.
'name': 'All Values Sent', // Product name. Required.
'sku': 'DD23444', // SKU/code.
'category': 'Party Toys', // Category or variation.
'price': '11.99', // Unit price.
'quantity': '1' // Quantity.
});
ga('ecommerce:send');

关于javascript - Google Analytics 电子商务跟踪无法正常工作 - 使用analytics.js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25436777/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com