Submit transaction is working fine when iam copy the basic example from analytics.js and hard code the parameter ,here iam using asynchronous method example. When i trying to pass dynamic valus from site it is not submitting transaction .
Please find the below code and update it and help
$.ajax({
type: "POST",
url: "/WSHub/wsTransactionReceipt.asmx/GetOrderDetailsforanalytics",
data: JSON.stringify(sdata),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
var Total = 0;
for (var i = 0; i < data.d.length; i++) {
Total = Total + parseFloat(data.d[i].UnitPrice);
}
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-48304226-1']);
_gaq.push(['_trackPageview']);
_gaq.push(['_addTrans',
'"' + objResult.SalesOrderNumber + '"',
'',
'"' + Total + '"',
'',
'',
'',
'',
''
]);
for (var i = 0; i < data.d.length; i++) {
_gaq.push(['_addItem',
'"' + objResult.SalesOrderNumber + '"',
'"' + data.d[i].SKUName + '"',
'"' + data.d[i].ProductName + '"',
'',
'"' + data.d[i].UnitPrice + '"',
'"' + data.d[i].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);
})();
}
});