kotmyrevich / analytics-issues

Automatically exported from code.google.com/p/analytics-issues
0 stars 0 forks source link

Transaction data is not sending to google analytics since 3rd NOV 2015 #792

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I am using enhanced ecommerce for collecting my ecommerce data. I have write 
the tracking code for sending website data to the google analytics. Form 3rd 
november 2015 I am unable to get my transaction data.
Please let me know the root cause for this.
My tracking code for sending data to the gooogle analytics is here under:

<script type="text/javascript">
        (function (i, s, o, g, r, a, m) {
            i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function () {
                (i[r].q = i[r].q || []).push(arguments)
            }, i[r].l = 1 * new Date(); a = s.createElement(o),
  m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; m.parentNode.insertBefore(a, m)
        })(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');

        ga('create', 'UA-6098039-13', 'auto');

        ga('require', 'ec');
    </script>

<script type="text/javascript">       
        $(document).ready(function () {
            var cartArray = $("#<%= hfProductList.ClientID %>").val();
            var transactionID = $("#<%= hfTransactionID.ClientID %>").val();
            var storeName = $("#<%= hfStoreName.ClientID %>").val();
            var shipping = $("#<%= hfShipping.ClientID %>").val();
            var tax = $("#<%= hfTax.ClientID %>").val();
            var orderTotal = $("#<%= hfOrderTotal.ClientID %>").val();
            var orderID = $("#<%= hfOrderID.ClientID %>").val();
            console.log('<<<<<<<<<<<<<<<<<<<Transaction ID : ' + transactionID)
            var jsonArray = jQuery.parseJSON(cartArray);
            $.each(jsonArray, function (i, item) {
                if (item != null) {
                    console.debug('BEGIN');

                    var _productPrice = "'" + parseFloat(item.Price) + "'";
                    var _orderTotal = "'" + parseFloat(orderTotal) + "'";
                    var _orderTax = "'" + parseFloat(tax) + "'";
                    var _shipping = "'" + parseFloat(shipping) + "'";
                    ga('ec:addProduct', {
                        'id': item.ProductId,
                        'name': item.ProductName,
                        'category': item.Category,
                        'price': _productPrice,
                        'quantity': item.Quantity
                    });
                    ga('ec:setAction', 'purchase', {
                        'id': orderID,
                        'affiliation': storeName,
                        'revenue': _orderTotal,
                        'tax': _orderTax,
                        'shipping': _shipping
                    });
                    ga('send', 'pageview');
                    console.debug('Product Price:' + _productPrice + ' Product Quantity:' + item.Quantity + ' Order Total:' + _orderTotal + ' Tax:' + _orderTax + ' Shipping:' + _shipping);
                    console.debug('END');
                }
            });
            console.log('-------------Sent to ecommerce universal google analytics-----------------');
            UpdateOrders(parseInt(orderID));
        });
        function UpdateOrders(orderID) {
            //debugger;
            var args = { OrderId: orderID }
            $.ajax({
                type: "POST",
                url: "/CheckoutCompleted.aspx/SetGoogleCommercegOrder",
                data: JSON.stringify(args),
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function () {
                    console.log('UpdateOrders Success   :   ' + orderID);
                },
                error: function () {
                    console.log('UpdateOrders Fail!' + orderID);
                }
            });
        }
    </script>

Original issue reported on code.google.com by Dooa....@gmail.com on 17 Nov 2015 at 7:31