google-analytics - Google Analytics(分析)-GA中未显示某些电子商务交易

标签 google-analytics transactions e-commerce google-tag-manager

我们已经在网站上实施了Google Analytics(分析)电子商务跟踪。我们注意到,Google Analytics(分析)缺少一些交易。只有一些数据丢失,而其他事务则被正确记录。

对于丢失的订单没有具体的模式(例如,所选产品,使用的设备...等)。

以下是将交易数据推送到分析的代码段。

    var products = [];

    for (i = 0; i < cart.lines.length; i++) {

                var cartItem = cart.lines[i];

                if (cartItem != null && cartItem != 'undefined') {

                    products.push({
                        'name': cartItem.cartProduct.name + ' ($' + cartItem.cost + ')',
                        'id': cartItem.cartProduct.id ,
                        'price': cartItem.cost,
                        'brand': 'My Brand XXX',
                        'category': cartItem.category,
                        'variant': 'My Brand XXX',
                        'quantity': 1 // Iterating item by item therefore hardcoding quantity to 1
                    });
                }
            }


            // Pushing ecommerce transaction data to data layer
            window.dataLayer = window.dataLayer || [];
            dataLayer.push({
                'ecommerce': {
                    'purchase': {
                        'actionField': {
                            'id': cart.referenceNumber,           // Transaction ID. Required for purchases and refunds.
                            'affiliation': store.name,
                            'revenue': cart.totalPrice,            // Total transaction value (incl. tax and shipping)
                            'tax': 0,
                            'shipping': cart.deliveryCharge,
                            'coupon': ''
                        },
                        'products': products
                    }
                },
                'event': 'purchase'
            });
        }


请注意,我可以访问完全填充的“购物车”和“商店”对象。
赞赏是否有人可以帮助您弄清楚是什么原因造成的。

最佳答案

好吧,您的代码看起来不错。没有任何具体方法可以确定导致此问题的原因。
您可以在上述特定代码中实施异常跟踪,这样您将了解导致问题的可能原因。

要使用GTM实施异常跟踪,您需要将以上代码包装在try catch块中,并在catch块中推送带有异常详细信息的datalayer事件。在GTM的另一侧,配置异常跟踪标记。

希望这会帮助你。如果需要实施异常跟踪的任何帮助,请告诉我。

关于google-analytics - Google Analytics(分析)-GA中未显示某些电子商务交易,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34734295/

相关文章:

google-analytics - 谷歌分析 : Regex pattern

javascript - Google Analytics 和omnature 如何在链接点击时进行ajax 调用并仍然跟踪链接

php - 订单历史通知

asp.net-mvc-3 - 是否有集成到自定义电子商务网站中的购物车?

mysql - 灵活搜索错误 : missing values

html - 如何制作此 iFrame 滚动

javascript - 如何在 Web 应用程序中处理用户审核日志(或其他频繁的客户端操作)?

php - 如何使用谷歌分析跟踪电子邮件中广告的点击次数?

java - 如何使用 jdbc 驱动程序编写事务?

sql - 取消查询后交易仍处于打开状态