在纯 analytics.js 实现中,您确实使用
ga('ec:setAction', 'remove');
以及描述被移除产品的产品属性
请参阅https://developers.google.com/analytics/devguides/collection/analyticsjs/enhanced-ecommerce#add-remove-cart
// describes the product being removed
ga('ec:addProduct', {
'id': product.id,
'name': product.name,
'category': product.category,
'brand': product.brand,
'variant': product.variant,
'price': product.price,
'quantity': product.qty
});
ga('ec:setAction', 'remove'); // notice 'remove' here
ga('send', 'event', 'UX', 'click', 'removed from cart'); // sends the action
如果您在 GTM 中使用 GTM 和 GA 原生标签,请参阅https://developers.google.com/tag-manager/enhanced-ecommerce#add和删除部分
// Measure the removal of a product from a shopping cart.
dataLayer.push({
'event': 'removeFromCart',
'ecommerce': {
'remove': { // 'remove' actionFieldObject measures.
'products': [{ // removing a product to a shopping cart.
'name': 'Triblend Android T-Shirt',
'id': '12345',
'price': '15.25',
'brand': 'Google',
'category': 'Apparel',
'variant': 'Gray',
'quantity': 1
}]
}
}
});