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

# Purchase tracking

> To calculate revenue figures, you need to track purchases. This is done with the `purchase` event.

A purchase is an event that tracks when a user has gone through the checkout process and paid for a set of products. Send it once, from your order-confirmation page.

Send events for **all** purchases — including ones that had nothing to do with Depict. Store-wide purchase data is the baseline that Depict's performance and analytics metrics are computed against.

<CodeGroup>
  ```typescript dpq theme={null}
  dpq("purchase", {
      transaction_id: "YOUR_TRANSACTION_ID",
      items: [{ item_id: "white-socks-xl", price: 89.9, quantity: 12 }],
      currency: "SEK",
  });
  ```

  ```typescript DPC instance theme={null}
  dpc.sendPurchaseEvent({
      transaction_id: "YOUR_TRANSACTION_ID",
      items: [{ item_id: "white-socks-xl", price: 89.9, quantity: 12 }],
      currency: "SEK",
  });
  ```
</CodeGroup>

## Field reference

* **`transaction_id`** — the id of the order in your system. It must be stable and unique per purchase: Depict deduplicates purchase events on it, so accidentally sending the same order twice is safe, but reusing an id across different orders loses data.
* **`items`** — one entry per order line:
  * **`item_id`** — the id this product was ingested with as its *transaction product id*. By default that is the SKU from your product data; on Shopify it is the variant's SKU, or the variant id for variants without a SKU. See [Which ID goes where](/api-guide/tracking/ids).
  * **`price`** — the final **per-unit** price, after taxes and discounts. If a discount applies to a whole line, spread it across the units. Items with price `0` (for example free gifts) are excluded from purchase metrics.
  * **`quantity`** — a whole number, at least 1.
* **`currency`** — the ISO 4217 code the prices are denominated in (e.g. `SEK`, `EUR`). Revenue is converted for display in the portal, so the code must be correct.

<Warning>
  A wrong `item_id` does not produce an error — the line item is accepted but
  can't be matched to your catalog, so it silently disappears from per-product
  metrics and attribution while still counting toward raw totals. After going
  live, check the "Tracking status" tab on
  [app.depict.ai](https://app.depict.ai) to confirm your purchases map to
  catalog products.
</Warning>

<Note>
  Purchase events are sent from the browser. If your checkout completes on a
  domain where DPC can't run, or you'd rather report purchases
  server-to-server, [contact us](mailto:hello@depict.ai) — we'll set it up
  together.
</Note>

<Check>
  Tracking is set up. Open the "Tracking status" tab on [app.depict.ai](https://app.depict.ai) to confirm that product card, product page, add-to-cart and purchase events arrive.
</Check>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.