analytics ecommerce tracking implementation on confirmation page
Hi All,
We are looking for at swift way of implementing ecommerce tracking on the confirmation page:
uCommerce/Confirmation.cshtml
Is there a module?
Or any tips to how we can use some of the order information, we need orderID, orderlines, currency, total and so on. Most default data on an order.
There is a roundtrip from DIBS, I am not sure how the system keeps track of the current orderID when landing on the confirmation page, when returning from DIBS https. ?
When you have the order object you can do something like this:
var orderid = order.OrderNumber;
var total = String.Format("{0:0.00}", order.OrderTotal).Replace(",", ".");
var tax = String.Format("{0:0.00}", order.VAT).Replace(",", ".");
var shipping = String.Format("{0:0.00}", order.ShippingTotal).Replace(",", ".");
var city = order.BillingAddress.City;
var state = order.BillingAddress.State;
var country = order.BillingAddress.Country.Name;
<script type="text/javascript">
_gaq.push(['_addTrans',
'@orderid', // transaction ID - required
'', // affiliation or store name
'@total', // total - required
'@tax', // tax
'@shipping', // shipping
'@city', // city
'@state', // state or province
'@country' // country
]);
@foreach (OrderLine orderline in order.OrderLines)
{
string lineSku = string.IsNullOrEmpty(orderline.VariantSku) ? orderline.Sku : orderline.VariantSku;
<text>
_gaq.push(['_addItem',
'@orderid', // transaction ID - required
'@lineSku', // SKU/code - required
'@orderline.ProductName', // product name
'@string.Empty', // category or variation
'@orderline.Price.ToString("N").Replace(",", ".")', // unit price - required
'@orderline.Quantity' // quantity - required
]);
</text>
}
_gaq.push(['_set', 'currencyCode', '@order.BillingCurrency.ISOCode']); // currency must be specified in the ISO 4217 standard
_gaq.push(['_trackTrans']); //submits transaction to the Analytics servers
</script>
Only one thing I'd like to add to it: Makesure to parse ProductName and remove any ' characters, fx. by doing a @orderline.ProductName.String().Replace("'","") (or something like that. I'm not a very good developer and this is just from the top of my head)
analytics ecommerce tracking implementation on confirmation page
Hi All,
We are looking for at swift way of implementing ecommerce tracking on the confirmation page:
uCommerce/Confirmation.cshtml
Is there a module?
Or any tips to how we can use some of the order information, we need orderID, orderlines, currency, total and so on. Most default data on an order.
There is a roundtrip from DIBS, I am not sure how the system keeps track of the current orderID when landing on the confirmation page, when returning from DIBS https. ?
Any tips much appreciated.
//Bille
Hi Peter,
uCommerce doesn't have a default way of doing e-commerce tracking, but you can use the Google Analytics e-commerce tracking functionality.
When you get redirected to the confirmation page, from a payment gateway, you should get an order guid as a query string parameter.
You can get all the order details you need, from the PurchaseOrder with the specified order guid.
Something like this:
When you have the order object you can do something like this:
Hi guys,
Very very cool, thank you very much for your input.
Kindly
Peter Bille
Nice one Nickolaj.
Only one thing I'd like to add to it: Makesure to parse ProductName and remove any ' characters, fx. by doing a @orderline.ProductName.String().Replace("'","")
(or something like that. I'm not a very good developer and this is just from the top of my head)
/Søren S.
is working on a reply...