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

# Tracking revenue

> Attach revenue to events and measure it in tests

To measure revenue, send it with the event and create an event goal that measures **Revenue**.

```javascript theme={"dark"}
window._pgnt = window._pgnt || [];
window._pgnt.push({
    kind: "event",
    label: "purchase",
    revenue: 2499 // $24.99
});
```

Then in pagent:

1. Go to **Tracking → Goals**, click **New goal** and choose **Event goal**.
2. Select the `purchase` event.
3. Open **Advanced** and set **Measure** to **Revenue**.
4. Click **Add Goal** and add the goal to your tests under **Editor → settings → Manage conversion goals**.

The same `purchase` event can also back a plain conversion goal (did the visitor buy at all) next to the revenue goal.

## Revenue format

Revenue sent with `window._pgnt.push` or the [REST API](/docs/guides/tracking/server-side-events) must be an **integer in cents** (minor units), not a decimal.

* ✅ `revenue: 999` is \$9.99
* ❌ `revenue: 9.99` is not an integer, so the event is dropped

| Amount | `revenue` |
| - | - |
| \$1.00 | `100` |
| \$9.99 | `999` |
| \$25.50 | `2550` |
| \$100.00 | `10000` |

Convert in your code:

```javascript theme={"dark"}
const revenueInCents = Math.round(cartTotal * 100);

window._pgnt.push({ kind: "event", label: "purchase", revenue: revenueInCents });
```

<Note>
  Events [observed from your dataLayer](/docs/guides/tracking/instrumentation) are the exception. Tag managers send order values like `value: 49.99`, so a definition's **Revenue path** is read in major units and converted for you: `49.99` is recorded as `4999`.
</Note>

## Common use cases

```javascript theme={"dark"}
window._pgnt = window._pgnt || [];

// E-commerce purchase
window._pgnt.push({ kind: "event", label: "purchase", revenue: 2499 });

// Subscriptions, one label per plan
window._pgnt.push({ kind: "event", label: "subscription_monthly", revenue: 2900 });
window._pgnt.push({ kind: "event", label: "subscription_annual", revenue: 29900 });

// Estimated value of a lead
window._pgnt.push({ kind: "event", label: "enterprise_lead", revenue: 5000 });

// Booking
window._pgnt.push({ kind: "event", label: "consultation_booking", revenue: 15000 });
```

## Properties

Add `properties` for context about the purchase. It must be an object or an array.

```javascript theme={"dark"}
window._pgnt.push({
    kind: "event",
    label: "purchase",
    revenue: 4999,
    properties: {
        order_id: "ORD-001",
        items: [
            { sku: "laptop", quantity: 1 },
            { sku: "mouse", quantity: 2 }
        ],
        payment_method: "credit_card"
    }
});
```

A **Sum** goal can add up a numeric property instead of revenue, for example the number of items.

## Best practices

1. **Always send cents** from your code.
2. **Send revenue once per order.** Reloading a thank-you page can report the same purchase twice. Guard with a flag, or report the purchase from your backend with the [REST API](/docs/guides/tracking/server-side-events).
3. **Keep revenue on real transactions.** For estimated values such as leads, use a separate label so they don't mix with actual sales.
4. **Leave outlier capping on.** One unusually large order can swing a test. The default **Automatic** capping handles this.

## Troubleshooting

**Revenue not showing**

* Check that `revenue` is an integer. Open your site with `?pagent_debug=1`: invalid events are logged in the console.
* Check the event arrives under **Tracking → Sources → Events**.
* Check the goal's **Measure** is set to **Revenue**.

**Values off by 100x**

* Reported events need cents. Observed dataLayer events are converted from major units automatically, so don't multiply those.

## Deprecated: revenue on conversions

Older integrations send revenue with `kind: "conversion"` and a Programmatic goal. This still works but is deprecated. Change `kind` to `"event"` and follow [Migrating from programmatic goals](/docs/guides/tracking/conversion-goals#migrating-from-programmatic-goals).

```javascript theme={"dark"}
// Deprecated
window._pgnt.push({ kind: "conversion", label: "purchase", revenue: 2499 });
```
