# Count sales from any checkout

> Count the sales of PayPal or your own checkout from your thank-you page: with code and an amount, or with the order id in its address.

Count the sales of any other checkout, PayPal or your own, from the page buyers reach once they have paid.

## Before you start

[Install CentPath](https://centpath.app/docs/install) on every page, your thank-you page included: the page buyers reach once they have paid, and at no other time. Each sale is counted from there, in the visit of the buyer who reached it, under the source that visit came from.

## 1. Tell CentPath how buyers pay you

1. In CentPath, open your site and go to **Setup** → **Sales**.
2. Under **How do buyers pay you?**, pick **Something else**. Setup shows both ways below, with your site's currency in the code.

## 2. Report each sale from your thank-you page

Pick the way that fits your thank-you page.

### With code: the sale and its amount

On your thank-you page, call this once the order is paid, with the order's own amount, currency and id:

```js
window.analytics.goal("purchase", {
  revenueMinorUnits: 4900, // 49.00 USD, in its smallest unit
  currency: "USD",
  id: orderId, // counts each sale once
});
```

1. Put the amount in `revenueMinorUnits` as a whole number in the currency's smallest unit: `4900` for 49.00 USD, `49` for 49 JPY.
2. Put the amount's three-letter currency code in `currency`. Each currency is counted apart, never converted: see [Currency](https://centpath.app/docs/currency).
3. Put the order's id in `id`, so a buyer who reloads the page counts once.

[Send goals from JavaScript](https://centpath.app/docs/javascript-goals#send-a-sale) has the details.

### Without code: the order id in the address

If you can't add code but your checkout can send buyers to a thank-you address of your choice, add this to its end, with the order's id in place of `ORDER_ID`:

```text
?ap_order=ORDER_ID
```

1. If the address already has a ?, start with & instead.
2. Use an id that is the order's own, so each sale counts once.

The sale counts, as an order with no amount: it adds to **Orders**, not to **Revenue**.

## Verify the setup

1. Make a purchase, or wait for your next sale, and let the thank-you page load.
2. Open your dashboard. If **Orders** isn't among the figures at the top, click **Configure** above them and turn it on. Then switch the chart to **Orders**: the sale is there, under the source of the visit that brought it. With an amount, it is in **Revenue** too.

## Troubleshooting

### A sale counts twice

The id changed between the two loads, or there was none. Send the order's own id, the same each time the page loads.

### A sale shows with no amount

An order id in the address counts the sale with no amount. Report it with code, as above, to count its amount.

### A sale reported with code never shows

Open your browser's console on the thank-you page. `[analytics] goal: bad revenueMinorUnits` means the amount isn't a whole number of 0 or more, or has no currency, and the sale was not sent. No message at all? Check that the page loads the snippet: [Check your installation](https://centpath.app/docs/verify-installation) shows how.

### Sales with an amount stopped counting

Your site accepts amounts from its payment provider alone: **Setup** → **Sales** → **Currency and amounts** has the box ticked. While it is, a sale your code sends with an amount is refused. Untick it if your thank-you page reports sales. [How revenue is counted](https://centpath.app/docs/revenue#only-amounts-from-your-payment-provider) explains why it is there.

### A visit to the thank-you page counts a sale that never happened

The page loads for people who didn't pay: a bookmark, a link shared, a test. Report the sale only when your checkout confirms the payment, and keep the page for buyers alone.
