2016-02-29 36 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. 

請注意最後一條評論 - 與頁面瀏覽一起發送交易。如果您不想要其他綜合瀏覽量,請使用活動。

相關問題