Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


These support forums are now closed for new topics and comments.
Please head on over to http://eureka.ucommerce.net/ for support.

  • Peter Bille 5 posts 25 karma points
    Dec 06, 2013 @ 13:56
    Peter Bille
    0

    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

     

     

  • Lars Horne-Mortensen 40 posts 184 karma points
    Dec 06, 2013 @ 14:32
    Lars Horne-Mortensen
    0

    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:

    Guid orderGuid;
    if (Guid.TryParse(Request.QueryString["OrderGuid"], out orderGuid)) {
        var purchaseOrder = PurchaseOrder.SingleOrDefault(x => x.OrderGuid == orderGuid);
    }
    
  • Nickolaj Lundgreen 233 posts 1132 karma points
    Dec 06, 2013 @ 14:40
    Nickolaj Lundgreen
    1

    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>
    
  • Peter Bille 5 posts 25 karma points
    Dec 06, 2013 @ 15:01
    Peter Bille
    0

    Hi guys,

    Very very cool, thank you very much for your input.

    Kindly
    Peter Bille

  • Soeren Sprogoe 575 posts 259 karma points
    Dec 09, 2013 @ 09:52
    Soeren Sprogoe
    0

    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.

Please Sign in or register to post replies

Write your reply to:

Draft