1

当我登陆确认页面时,我运行以下代码。

var purchaseObject = {
  'id': $OrderID,
  'revenue': $total,
  'shipping': $deliverycost
};
if (couponCode.length) {
  purchaseObject['coupon'] = couponCode;
}
ga('ec:setAction', 'purchase', purchaseObject);
ga('ec:send');

两个发送都会生成错误消息。

插件“ec”没有方法“send”。

调用插件方法时出错:{0: "ec:send"}

我已经添加了

ga('require', 'ec');

在头脑中,其他事件有效,所以我不明白为什么发送不起作用。

4

2 回答 2

4

EEC 没有发送方法,您使用电子商务数据设置操作,这将与下一个综合浏览量(或其他交互)一起发送。请参阅Google 文档中的示例:

// Transaction level information is provided via an actionFieldObject.
ga('ec:setAction', 'purchase', {
  'id': 'T12345',
  'affiliation': 'Google Store - Online',
  'revenue': '37.39',
  'tax': '2.85',
  'shipping': '5.34',
  'coupon': 'SUMMER2013'    // User added a coupon at checkout.
});

ga('send', 'pageview');     // Send transaction data with initial pageview.

请注意最后一条评论 - 交易与综合浏览量一起发送。如果您不想再次浏览网页,请使用事件。

于 2016-02-29T16:09:06.323 回答
1

您可以通过事件发送它:

ga('ec:setAction', 'purchase', {          // Transaction details are provided in an actionFieldObject.
  'id': 'T12345',                         // (Required) Transaction id (string).
  'affiliation': 'Google Store - Online', // Affiliation (string).
  'revenue': '37.39',                     // Revenue (currency).
  'tax': '2.85',                          // Tax (currency).
  'shipping': '5.34',                     // Shipping (currency).
  'coupon': 'SUMMER2013'                  // Transaction coupon (string).
});
ga('send','event','Ecommerce','Purchase','revenue', {nonInteraction: true});
于 2019-02-26T11:56:18.347 回答