# Purchase

{% hint style="info" %}
This section is relevant for both **FHR** and **XO** customers.
{% endhint %}

**Purchase** actions are key to analyzing performance, as they are used to calculate purchase conversion rates and revenues. They can only be performed on confirmation of purchase.

{% hint style="warning" %}
You should send a new **purchase** event for each distinct product, even if they are **purchased** as part of the same action.

To group multiple purchases, use the `orderId` field as described below.
{% endhint %}

### Properties

```json
{
    "action":"purchase",
    "target": {
        "product":"product-id"
    },
    "metadata": {
        "orderId": "order-id",
        "price": 3250,
        "quantity": 1,
        "currency": "EUR"
    }
}
```

| Properties          | Context | Description                                                                                                                                                                                                                                                  |
| ------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `action`            | All     | Must be specified as "purchase"                                                                                                                                                                                                                              |
| `target.product`    | All     | The ID of the product that was purchased; must be identical with the product ID used in FHR/XO, i.e. `secondID` [in the FHR response query](https://crownpeak.gitbook.io/product-discovery/tracking-and-sending-events/activity-object#fhr-response-mapping) |
| `metadata.*`        | All     | Additional information, such as **context** or **locale**                                                                                                                                                                                                    |
| `metadata.quantity` | All     | The quantity of the product that was purchased                                                                                                                                                                                                               |
| `metadata.price`    | All     | <p>The price of the product that was purchased; must:</p><ul><li>be <strong>in cents</strong> (i.e. without decimals)</li><li>be the product price, not the purchase total</li><li>take into account any discounts applied to the purchase</li></ul>         |
| `metadata.currency` | All     | The **currency** of the price, in [**ISO 4217**](https://en.wikipedia.org/wiki/ISO_4217) format                                                                                                                                                              |
| `metadata.orderId`  | All     | The ID of the purchase order as defined by your platform                                                                                                                                                                                                     |

{% hint style="danger" %}
Each tracker key can only be used with a single currency.
{% endhint %}

{% hint style="info" %}
Use the `metadata.orderId` to group purchase events, i.e. when a customer buys multiple products together.
{% endhint %}

{% hint style="info" %}
You do **not** need to include a **source ID** for this event.
{% endhint %}

<details>

<summary>Example: Purchase</summary>

```json
{
    "action":"purchase",
    "target": {
        "product":"83647582"
    },
    "metadata": {
        "orderId": "ec1851da-bff2-495c-b757-c162d9a079bd",
        "price": 3250,
        "quantity": 2,
        "currency": "EUR",
        "locale": "en_GB"
    }
}
```

</details>
