2016-02-29 88 views
1

当我着陆确认页时,我运行以下代码。发送增强型电子商务数据

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

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

插件“ec”没有方法“发送”。

错误调用插件方法:{0: “EC:发送”}

我已经在头和其他加

ga('require', 'ec'); 

事件的作品,所以我不明白为什么发送不起作用。

回答

2

EEC没有发送方法,您使用电子商务数据设置操作,并将其与下一个浏览量(或其他交互)一起发送。请参阅example from the Google documentation:

// 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. 

请注意最后一条评论 - 与页面浏览一起发送交易。如果您不想要其他综合浏览量,请使用活动。

相关问题