對電子商務事件套用折扣

如要為電子商務事件中的商品套用折扣,請加入 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 參數。

如果優待券會為整個訂單 (活動層級) 套用折扣,請將折扣分配給活動中的項目,確保項目層級報表準確無誤。每個項目物件包含:

  1. 新增 discount 參數,並為商品分配單位折扣值。
  2. price 設為單價減去分配給該項目的單位折扣。

您也可以建立自訂指標,以產生事件層級折扣報表。