Apply a discount to an ecommerce event

  • Use the discount parameter to apply discounts to items in ecommerce events, representing the total discount amount, not the percentage.

  • The example demonstrates applying a per-item discount during a purchase event using the discount parameter in gtag.js.

  • Reporting on discounts is possible using dimensions like item_coupon, order_coupon, and metrics like item_revenue.

  • For event-level discounts, create a custom metric to track and report them separately.

You can apply a discount to an item in an ecommerce event by adding the discount parameter with the value of the discount. Don't use the percentage discount with the discount parameter.


Example

An online store charges $6 per pair of socks. A customer purchases 3 pairs of socks with a $2 discount per pair. In this example, the purchase event tag would look like the following:

dataLayer.push({ ecommerce: null });
dataLayer.push({
  event: "purchase",
  ecommerce: {
    transaction_id: "T_12345",
    coupon: "socksSale",
    value: 12.00, // value = quantity x sale price
    currency: "USD", // The currency of the value, discount, and price
    items: [
    {
      item_id: "SKU_12345",
      item_name: "Socks",
      discount: 2.00, // The discount per item
      price: 4.00, // The sale price is the per item list price (6.00) minus discount (2.00)
      quantity: 3 // The number of items sold
    },
  ]}
});

Report on the discount

The following dimensions and metrics allow you to report on discount:

Dimension or metric Description
Item coupon The coupon used to purchase an item (e.g., a product you sell).
Order coupon The coupon name or code that you specify for discounted items.
Item revenue The total revenue from items only, excluding tax and shipping. Item revenue = quantity x price.

If you want to apply event-level discounts, you must create your own custom metric to report on event-level discounts.