> ## Documentation Index
> Fetch the complete documentation index at: https://docs.upstackdata.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Value & formulas

> Send profit, margin, a fixed amount, or your own formula instead of the event's own value.

By default, destinations receive the value already on the event. You can override it so your ad platforms optimize on something else — profit instead of revenue, or a flat value for leads.

Set it while creating a mapping — [global](/guides/custom-events/global-event-mappings) or [destination](/guides/custom-events/destination-event-mappings) — by turning on **Override event value** and picking under **Set value to**.

## What you can send

What's available depends on the base event:

| Base event                                         | Options                                                         |
| -------------------------------------------------- | --------------------------------------------------------------- |
| `purchase`                                         | Event value, Net Revenue, CM1, CM2, Fixed value, Custom formula |
| `add_to_cart`, `initiate_checkout`, `view_content` | Event value, Net Revenue, Fixed value, Custom formula           |
| Any other event                                    | Event value, Fixed value, Custom formula                        |

**Net Revenue** comes straight off the Shopify order. **CM1** and **CM2** subtract your [cost settings](/analytics/cost-settings) from it, which needs the full order — so they're purchase-only:

* `CM1 = Net Revenue − product cost`
* `CM2 = CM1 − shipping, handling, and payment fees`

If you pick an option the event can't supply, Upstack sends the event's own value rather than a wrong number.

## Custom formula

Two ways to build one:

* **Simple** — pick a value and adjust it step by step, like a calculator: **Event value × 0.7**. Each part is a metric, a field (`data.fieldName`), or a number.
* **Advanced** — type the formula directly, with autocomplete. Use `+ − * /` and parentheses.

| Goal                      | Formula                            |
| ------------------------- | ---------------------------------- |
| 70% of the event value    | `data.value * 0.7`                 |
| Profit                    | `orders.net_revenue - orders.cogs` |
| Value minus a flat fee    | `data.value - 15`                  |
| Scale a custom lead value | `data.leadValue * 0.4`             |

<Note>
  **A missing field never zeroes your value.** If a formula references a field the event didn't send, Upstack skips the override and forwards the event's own value. A field that is present and genuinely `0` is used as `0`.
</Note>

## Operands

**From the event** — any event:

| Operand        | What it is                                                |
| -------------- | --------------------------------------------------------- |
| `data.value`   | The value already on the event                            |
| `data.<field>` | Any custom field the event carries, e.g. `data.leadValue` |

**Revenue** — `purchase`, `add_to_cart`, `initiate_checkout`, `view_content`:

| Operand                  | What it is                                         |
| ------------------------ | -------------------------------------------------- |
| `orders.total_revenue`   | What the customer paid, including tax and shipping |
| `orders.gross_revenue`   | Sales before discounts and refunds                 |
| `orders.net_revenue`     | Sales after discounts and refunds                  |
| `orders.subtotal`        | Line items only — no tax, no shipping              |
| `orders.tax`             | Tax on the order                                   |
| `orders.discount_amount` | Discounts applied                                  |
| `orders.refund_amount`   | Amount refunded                                    |
| `orders.units`           | Number of items                                    |

**Costs** — `purchase` only, from your [cost settings](/analytics/cost-settings):

| Operand                         | Where it comes from                                 |
| ------------------------------- | --------------------------------------------------- |
| `orders.cogs`                   | Product cost of the items sold                      |
| `orders.shipping_cost`          | Your Shipping settings                              |
| `orders.handling_cost`          | Your handling fee                                   |
| `orders.gateway_cost`           | Your payment processing fees                        |
| `orders.other_cogs`             | Order fees you created, categorised **COGS**        |
| `orders.other_fulfillment_cost` | Order fees you created, categorised **Fulfillment** |
| `orders.other_transaction_cost` | Order fees you created, categorised **Transaction** |

## Related

<CardGroup cols={2}>
  <Card title="Global event mappings" icon="globe" href="/guides/custom-events/global-event-mappings">
    Create a mapping once and send it everywhere.
  </Card>

  <Card title="Cost settings" icon="coins" href="/analytics/cost-settings">
    Configure the costs behind Net Revenue, CM1, and CM2.
  </Card>

  <Card title="Custom events overview" icon="bolt" href="/guides/custom-events/how-to-create-custom-event-triggers">
    What custom events are and when to use them.
  </Card>

  <Card title="Destination event mappings" icon="sliders" href="/guides/custom-events/destination-event-mappings">
    Set a different value for one destination.
  </Card>
</CardGroup>
