> ## 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.

# purchase Event

> Track when an order is completed

Fires when an order is completed. This is the most important e-commerce event — it's used for conversion tracking, ROAS calculation, and optimization across all ad platforms.

<Note>
  **Shopify:** Automatically tracked on the order confirmation page (thank you page) and via server-side webhooks.
</Note>

## JavaScript

```javascript theme={null}
window._upstack('track', 'purchase', {
  orderId: 'ORD_12345',
  value: 149.99,
  currency: 'USD',
  tax: 12.50,
  shipping: 5.99,
  items: [
    {
      id: 'SKU_001',
      name: 'Blue Running Shoes',
      price: 89.99,
      quantity: 1,
      brand: 'Nike',
      category: 'Shoes/Running'
    },
    {
      id: 'SKU_002',
      name: 'Running Socks',
      price: 14.99,
      quantity: 2,
      brand: 'Nike',
      category: 'Accessories/Socks'
    }
  ],
  email: 'customer@example.com'
}, 'ORD_12345');
```

<Note>
  The third parameter (`'ORD_12345'`) is a deduplication ID. It prevents duplicate purchase events from being sent to destinations if the event fires multiple times.
</Note>

Minimal example:

```javascript theme={null}
window._upstack('track', 'purchase', {
  orderId: 'ORD_12345',
  value: 149.99,
  currency: 'USD',
  items: [{ id: 'SKU_001', name: 'Blue Running Shoes', price: 89.99, quantity: 1 }]
}, 'ORD_12345');
```

## Properties

| Property | Type   | Required | Description                                                                |
| -------- | ------ | -------- | -------------------------------------------------------------------------- |
| orderId  | string | Yes      | Unique order identifier                                                    |
| value    | number | Yes      | Total order value                                                          |
| currency | string | Yes      | ISO 4217 currency code                                                     |
| items    | array  | Yes      | Products purchased (see [Item Object](/pixel/standard-events#item-object)) |
| tax      | number | No       | Tax amount                                                                 |
| shipping | number | No       | Shipping cost                                                              |
| email    | string | No       | Customer email (improves identity matching)                                |

<Warning>
  **Important:** The `value` property should match what you want reported to ad platforms. Discrepancies between Shopify order totals and reported CAPI revenue are the most common attribution debugging issue.
</Warning>

## When to Fire

* Order confirmation page load
* After successful payment confirmation
* Shopify `orders/create` webhook (server-side)

## Related Events

* [initiate\_checkout](/pixel/events/initiate-checkout) — Starting the checkout
* [add\_payment\_info](/pixel/events/add-payment-info) — Before completing purchase
* [refund](/pixel/events/refund) — When order is refunded
