您可以通过添加 discount 参数并设定折扣值,对电子商务事件中的商品应用折扣。请勿为 discount 参数使用百分比。
示例
某客户将 8 美元的折扣代码 (“SAVE20”) 应用于包含两件某商品和一件另一商品的订单。折扣分配方式为:第一个商品每件 2 美元,第二个商品每件 4 美元。以下是此示例的 purchase 事件代码:
// A user applies the coupon code "SAVE20" to their entire order.
// The order contains two items, each receiving a portion of the discount.
gtag("event", "purchase", {
'transaction_id': "T_12345",
'value': 32.00, // Total value after all discounts
'currency': "USD",
'coupon': "SAVE20", // Order-level coupon code
'items': [
{
'item_id': "SKU_123",
'item_name': "Blue Widget",
'price': 8.00, // Unit price after discount (original 10.00 - 2.00 discount)
'discount': 2.00, // Unit discount
'quantity': 2,
'coupon': "SAVE20" // Optional: Item-level coupon can match order-level
},
{
'item_id': "SKU_456",
'item_name': "Red Widget",
'price': 16.00, // Unit price after discount (original 20.00 - 4.00 discount)
'discount': 4.00, // Unit discount
'quantity': 1,
'coupon': "SAVE20"
}
]
});
报告折扣
| 维度或指标 | 说明 |
|---|---|
| 商品优惠券 | 用于购买商品(例如您销售的产品)的优惠券。 |
| 订单优惠券 | 您为折扣商品指定的优惠券名称或代码。 |
| 商品折扣金额 | 仅商品带来的折扣总价值。商品折扣金额 = quantity x discount。 |
| 商品收入 | 仅商品带来的总收入(不含税费和运费)。商品收入 = quantity x price。 |
处理事件级和商品级折扣
您可以为整个订单(事件级)或特定商品(商品级)添加优惠券。
- 订单级:如需将优惠券应用于整个交易,请在事件级(
items数组之外)添加coupon参数。 - 商品级:如需将优惠券应用于特定商品,请在
items数组中相应对象的coupon参数内添加优惠券。
如果优惠券为整个订单(事件级)提供折扣,您应将该折扣分配给相应事件中的各个商品,以确保商品级报告的准确性。在每个商品对象中:
- 添加
discount参数,并为相应商品分配单位折扣值。 - 将
price设置为单价减去商品的分配单位折扣。
您还可以创建自定义指标来报告事件级折扣。