我尝试在google analytic上推送交易的历史记录。 我把所有事情都格式化了,因为我最了解我的知识。 下面是我推送数据的代码是代码中的任何错误。??
function transactionTracking(itemArray, itemPrice) {
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXX-X']); // your GA ID
_gaq.push(['_trackPageview']); // track the page view
var transID = document.getElementById('<%=lblTransID.ClientID%>').innerHtml;
var totalAmmount = document.getElementById('<%=lblCost.ClientID%>').innerHtml;
var moduleName = document.getElementById('<%=lblModuleName.ClientID%>').innerHtml;
_gaq.push(['_addTrans',
"'" + transID + "'", // transactionID
'abcd', // store
"'" + totalAmmount + "'"
]);
itemArray = JSON.parse(itemArray);
for (var a = 0; a <= itemArray.length; a++) {
_gaq.push(['_addItem',
"'" + transID + "'", // transactionid ID
"'" + moduleName + "'", // SKU/code
"'" + itemArray[a] + "'", // product name
"'" + itemPrice[a] + "'", // unit price
'1' // quantity
]);
}
_gaq.push(['_trackTrans']);
(function () {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
}
答案 0 :(得分:1)
我的_addTrans
代码缺少shipping, tax, country, state, city
值,请检查here
_gaq.push(['_addTrans',
'1234', // transaction ID - required
'Womens Apparel', // affiliation or store name
'28.28', // total - required
'1.29', // tax
'15.00', // shipping
'San Jose', // city
'California', // state or province
'USA' // country
]);