结帐时Google Analytics增强型电子商务有效负载过大

时间:2016-09-06 03:55:45

标签: google-analytics e-commerce analytics

似乎:

ga('send', 'pageview');

我们不知道如何处理大型有效负载(超过8K),当我们发送超过100种产品的大型交易时,页面展示只会尝试在单个信标帖子中发送所有项目

products.forEach(product => ga('ec:addProduct', ...) ) // 100 products
ga('ec:setAction', 'purchase', ...)
ga('send', 'pageview');

结果是

raven.js:80 Payload size is too large (11352).  Max allowed is 8192.

我们只关注以下文档:enhanced-ecommerce#measuring-transactions

2 个答案:

答案 0 :(得分:3)

对Google Analytics端点的HTTP请求限制为8Kb(或更准确地说是8192字节)。
有一个很好的博客here讨论如何管理这种溢出 我们的想法是,如果阵列中的对象(产品)数量大于您定义的数量,假设为35,并且访问者已选择显示100个产品,解决方案是自动发送3次点击数据以避免触及8Kb限制。

<script>
if (product.length > 0 || promo.length > 0) {
    var maxProducts = 35;                   // Max objects that will be sent with 1 hit.
    var ecomm = product.concat(promo);      // Merge product & promo into 1 array that we use in the add to cart & click tracking.
while(product.length || promo.length) {
    var p1 = product.splice(0,maxProducts); // Split the product array into arrays with max 35 objects
    var p2 = promo.splice(0,maxProducts);   // Split the promo array into arrays with max 35 objects
    dataLayer.push({
        'ecommerce': {
            'promoView': {
                'promotions': p2
                },
            'impressions': p1
        },
        'event': 'impression', // GTM Event for Impression tracking
        'eventCategory':'Ecommerce','eventAction':'Impression'
        });
    };
};
</script>

答案 1 :(得分:1)

经过几次测试后,似乎我们找到了解决方案,我们将交易分成20个批次,最后我们发送交易全球数据(如税和运费)。每个批次都通过发送交易ID连接到交易。

Dim notificationList As List(Of INamedNotification)
if type = "Warning" Then 
    itemList = warningList
Else If type = "Info"
    itemList = infoList  
End If

Dim item = notificationList.Where(Function(x) x.Name = "Foo").FirstOrDefault()
相关问题