# Unique Events

Unique events are normal Bento events with a little extra structure. You send them the same way you send any other event, but you include a `unique.key` plus `value.amount` and `value.currency` when you want to track a purchase.

This is most useful for `$purchase` events. It lets Bento count revenue correctly without double-counting the same order if a thank you page reloads or your app retries the event.

## What makes an event unique

A unique event still has the same core event shape:

- `type`
- `email`
- optional `fields`
- optional `details`

What makes it unique is the `details.unique.key`.

That key should be a stable identifier for the action you are tracking, such as an order ID, invoice ID, or checkout ID. If the same purchase event is sent more than once with the same key, Bento can treat it as the same unique purchase instead of a second one.


> Use a real business identifier for the key. An order number is better than a random value generated in the browser.


## When to use unique events

Use unique events when the same action should only be counted once and it has a monetary value attached to it.

Most teams use them for:

- first-time purchases
- repeat orders
- subscription renewals
- any backend-confirmed revenue event

If you are just tracking behavior like page views, button clicks, or feature usage, a normal event is usually enough.

## Required purchase data

For purchase tracking, Bento expects a few fields inside `details`:

- `unique.key`: a stable purchase identifier like `order-123`
- `value.amount`: the purchase amount in cents
- `value.currency`: the ISO currency code, like `USD`

You can also include extra purchase context like cart items, product IDs, SKUs, or plan names.

## Example payload

Here is a simple Ruby example for a unique purchase event:

```ruby
Bento::Events.track(
  email: 'test@test.com',
  type: '$purchase',
  fields: { first_name: 'Jesse' },
  details: {
    unique: { key: 'order-123' },
    value: { currency: 'USD', amount: 8000 }, # in cents
  }
)
```

The same idea applies in other SDKs and in the [Events API](/docs/events_api). The important part is the shape of `details.unique` and `details.value`.

## How unique events behave

Because unique events are still events, you can use them everywhere you already use event data in Bento:

- trigger flows from `$purchase`
- build segments from purchase history
- personalize emails with purchase details
- track customer lifetime value from purchase amounts

If you are sending purchase events from the browser with Bento.js, see [Bento.js (Web Tracking)](/docs/web_analytics). If you are sending them from your backend or SDK, see [Events API](/docs/events_api). For the broader event model, see [Events](/docs/concepts/events).