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.

  • Thomas Jeppesen 2 posts 22 karma points
    Mar 18, 2013 @ 21:38
    Thomas Jeppesen
    0

    How to setup eCommerce for Analytics?

    Guess the headlines says it all.... But I could use some hints on how to setup  eCommerce for Google Analytics?

  • Nickolaj Lundgreen 233 posts 1132 karma points
    Mar 19, 2013 @ 10:37
    Nickolaj Lundgreen
    0

    Just to be sure - do you want to track conversion rate, or just add the normal google analytics script to track visitors?

  • Thomas Jeppesen 2 posts 22 karma points
    Mar 19, 2013 @ 18:55
    Thomas Jeppesen
    0

    Conversion rate - the script is in place

  • Adam Jenkin 71 posts 226 karma points
    Mar 19, 2013 @ 22:03
    Adam Jenkin
    0

    Great question! Has got me thinking about analytics on a commerce site I am in the middle of building.

    I presume you have already seen this?

    https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingEcommerce

    If not, its a good place to start. 

     

  • Nickolaj Lundgreen 233 posts 1132 karma points
    Mar 20, 2013 @ 09:22
    Nickolaj Lundgreen
    0

    What i have done, is adding a script on the OrderApproved page (the page the user gets redirected to after the payment).

     //Conversion:
        var conversionID = "ID HERE";
        var conversionLabel = "Conversion label";
    
        <!-- Google Code for OrderCompleted Conversion Page -->
        <script type="text/javascript">
        /* <![CDATA[ */
        var google_conversion_id = @conversionID;
        var google_conversion_language = "en";
        var google_conversion_format = "3";
        var google_conversion_color = "ffffff";
        var google_conversion_label = @conversionLabel;
        var google_conversion_value = 1;
        /* ]]> */
        </script>
        <script type="text/javascript" src="http://www.googleadservices.com/pagead/conversion.js">
        </script>
        <noscript>
        <div style="display:inline;">
        <img height="1" width="1" style="border-style:none;" alt="" src="http://www.googleadservices.com/pagead/conversion/@conversionID/?value=1&amp;label=@conversionLabel&amp;guid=ON&amp;script=0"/>
        </div>
        </noscript>
    
    
        //Commerce:
    
        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', // order ID - required
                '', // affiliation or store - 
                '@total',// total - required. Bemærk decimaladskiller er .
                '@tax', // tax/Moms
                '@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', // order ID - necessary to associate item with transaction
                        '@lineSku', // SKU/code – required    
                        '@orderline.ProductName', // product name - required    
                        '@string.Empty', // category 
                        '@orderline.Price.ToString("N").Replace(",", ".")', // unit price - required
                        '@orderline.Quantity' // quantity - required
                ])
            ;
            </text>
        }
        _gaq.push(['_trackTrans']);
    </script>
        

    Im pretty sure there must be a better way - but this is the solution im at right now (feel free to make improvement sugestions)

  • Morten Skjoldager 440 posts 1499 karma points
    Mar 20, 2013 @ 11:24
    Morten Skjoldager
    0

    Another great tip is to add a goal page in analytics. That way you can track from which source the purchase was from (referal links, google, facebook etc.)

  • Ben 5 posts 71 karma points
    Jul 04, 2014 @ 17:12
    Ben
    0

    you don't actually need to add a separate goal page in analytics if you're using the google ecommerce tracking scripts as you can view all the same info e.g. source/medium from the ecommerce transaction report.

  • Martin 181 posts 740 karma points
    Jul 05, 2014 @ 11:03
    Martin
    0

    hi Thomas,

    Google has some nice documentation how to implement their eCommerce tracking. for universal tracking: https://developers.google.com/analytics/devguides/collection/analyticsjs/ecommerce or classic tracking: https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingEcommerce

    Basically your confirmation page should write a script tag out containing the javascript with line order lines and so forth. If you're using razor this is piece of cake to implement. You can copy paste googles example code right into your view/macro and then replace their values with information from your basket. And then you should be good to go. 

    Make sure to check whether the order already has been tracked. Otherwise you might get some faulty information due to double tracking.

     

    Best regards
    Martin

     

    EDIT: Forget my post. Appearently the forum chose not to show any posts before I did my post... And now I see the post is very old....

Please Sign in or register to post replies

Write your reply to:

Draft