使用GA Enhanced电子商务为单个结帐步骤注册多个选项的最佳方法是什么?

如文档所述:

// Called when user has completed shipping options.
function onShippingComplete(stepNumber, shippingOption) {
  ga('ec:setAction', 'checkout_option', {
    'step': stepNumber,
    'option': shippingOption
  });

  ga('send', 'event', 'Checkout', 'Option', {
     hitCallback: function() {
       // Advance to next page.
     }
  });
}


问题是我们一步一步收集运费和付款方式,我们想跟踪这两个选择。这是我们最初的想法:

// Called when user has completed shipping and payment options.
function onStepComplete(stepNumber, shippingOption,paymentOption ) {
  ga('ec:setAction', 'checkout_option', {
    'step': stepNumber,
    'option': shippingOption
  });

ga('ec:setAction', 'checkout_option', {
    'step': stepNumber,
    'option': paymentOption
  });

  ga('send', 'event', 'Checkout', 'Option', {
     hitCallback: function() {
       // Advance to next page.
     }
  });
}


这项工作会按预期进行吗?之后我们可以正确地进行细分吗?

最佳答案

将checkout_option更改为checkout-似乎是Google处理两种独立事件的方式,以及每种数据需要哪些数据才能在增强型电子商务中工作。我本人也面临同样的问题,并且已设法解决该问题。

基于您的代码的示例为:

    // Called when user has completed shipping and payment options.
function onStepComplete(stepNumber, shippingOption,paymentOption ) {
  ga('ec:setAction', 'checkout', {
    'step': stepNumber,
    'option': shippingOption
  });

ga('ec:setAction', 'checkout', {
    'step': stepNumber,
    'option': paymentOption
  });

  ga('send', 'event', 'checkout', 'option', {
     hitCallback: function() {
       // Advance to next page.
     }
  });
}

10-08 18:17