# Revenue from your shop

> See what your visitors buy, which sources and campaigns bring the money, and which customers come back.

Visitors are nice, orders pay the bills. Connect your shop or payment platform and Okidoki puts your revenue next to your visitors: how much came in, how many orders, the average order, how much each visitor is worth, and which sources and campaigns bring the money.

Connecting works on every plan. Free shows sales and orders in total and by channel for the last 30 days. Plus shows all of your history, which sources and campaigns sell, revenue per visitor, customers who come back and what a customer is worth. See [Plans and pricing](https://docs.okidoki.sh/plans).

Okidoki works with **Shopify**, **WooCommerce**, **BigCommerce**, **Stripe**, **Gumroad**, **Lemon Squeezy**, **Polar**, **Paddle**, **Squarespace**, **Wix**, **Klarna Checkout**, **Svea Checkout**, **Qliro Checkout** and **Segment**. Under **Settings → Connections**, find **Revenue** and click where you sell. Shopify, WooCommerce, BigCommerce and Stripe connect in one click. If the Shopify button is grey, Shopify is still reviewing the Okidoki app; connect by hand with the steps below meanwhile. For the others, Okidoki shows the address to copy and a few short steps, all in the same place. When the first order or test arrives, the platform shows **Connected ✓**.

## How it works

Your shop sends each paid order to Okidoki as a webhook, a small message to an address that is unique to your site. Okidoki checks the signature with a signing secret, so nobody else can send orders in your name, and keeps only:

| Kept | Never kept |
| --- | --- |
| The amount and currency | The customer's name, email or address |
| When the order was paid | What they bought |
| Where the order came from: the referring site and campaign tags, as your shop recorded them | The shop's order number, which is only kept as a scrambled digest to skip duplicates |
| | The customer number, which is only kept as a digest with a secret salt for your site, to tell a returning customer from a new one. Nobody can turn it back into the number |

Orders are never linked to a visit or a person. The source of an order comes from your shop itself: Shopify records the landing page and referring site of every order, WooCommerce its own order attribution, and Gumroad the referring site and the tags on the product link. Stripe, Lemon Squeezy, Polar and Paddle carry the campaign tags your site puts on the checkout. Squarespace and Wix orders have no source; Klarna, Svea and Qliro orders have one if your shop sends the tags along. Segment orders get the campaign Segment sends with the call (`context.campaign`).

## Connect Shopify

Click **Shopify** and **Connect Shopify**, sign in to your store and press **Install**. That is all. To set it up by hand instead:

1. In Shopify, open Settings, then Notifications, then Webhooks.
2. Create a webhook for the event "Order payment", format JSON, with this address: https://okidoki.sh/api/revenue/rev_...
3. Optional: create one more for "Order cancellation" with the same address, so cancelled orders are taken off.
4. Copy the signing secret that Shopify shows under the list of webhooks ("Your webhooks will be signed with ...") and paste it into Okidoki.

## Connect WooCommerce

Click **WooCommerce** and **Connect WooCommerce**. Okidoki opens your store; log in to WordPress if asked and click **Approve**. Okidoki adds two webhooks to your store and does not keep the key. Your store needs WooCommerce 8.5 or later for orders by source, and must use https.

Using [the Okidoki plugin](https://okidoki.sh/downloads/okidoki-analytics.zip)? Then **Connect to Okidoki** in the plugin does this too, and only sends what the report needs: no names, addresses or products, and the buyer's email only as a SHA-256.

To set it up by hand instead:

1. In WordPress, open WooCommerce, then Settings, then Advanced, then Webhooks, and click "Add webhook".
2. Name it Okidoki, set Status to Active and Topic to "Order updated".
3. Paste the address in "Delivery URL": https://okidoki.sh/api/revenue/rev_...
4. Paste the secret from Okidoki in "Secret" (oki_...) and click "Save webhook".

## Connect BigCommerce

Click **BigCommerce** and **Connect BigCommerce**, and press **Install** in your store. The Okidoki app puts the tag on every page of the store and sends each order to Okidoki. Okidoki reads the order's total, currency and time from the store, and the customer number or email only as a fingerprint. Removing the app in BigCommerce removes the tag and the webhooks. BigCommerce does not record where an order came from, so its orders have no source.

## Connect Stripe

Click **Stripe** and **Connect Stripe**, sign in and allow Okidoki to read your payments. To set it up by hand instead:

1. In Stripe, open Developers, then Webhooks, and choose "Add destination".
2. Choose the events checkout.session.completed, checkout.session.async_payment_succeeded and invoice.paid.
3. Choose "Webhook endpoint" and use this address: https://okidoki.sh/api/revenue/rev_...
4. Open the new destination, reveal the signing secret (it starts with whsec_) and paste it into Okidoki.
5. Optional: put utm_source, utm_medium and utm_campaign in the Checkout session metadata to see revenue by campaign.

## Connect Gumroad

When **Connect Gumroad** shows, click it, sign in to Gumroad and press **Authorize**: Okidoki subscribes your store's address to sales and refunds, nothing to copy. Otherwise:

1. In Gumroad, open Settings, then Advanced.
2. Paste the address in "Ping endpoint": https://okidoki.sh/api/revenue/rev_...
3. Click "Update settings", then "Send test ping to URL". Okidoki shows Connected when it arrives.

Gumroad does not sign its messages, so the address itself is the secret. Keep it to yourself, and if it leaks, remove Gumroad in Okidoki and add it again for a new address.

## Connect Lemon Squeezy

The quickest way: in Lemon Squeezy, open **Settings → API**, create a key and paste it into Okidoki. Okidoki adds the webhook for you and does not keep the key. Or by hand:

1. In Lemon Squeezy, open Settings, then Webhooks, and click the + button.
2. Paste the address in "Callback URL": https://okidoki.sh/api/revenue/rev_...
3. Paste the secret from Okidoki in "Signing secret" (oki_...).
4. Tick order_created, order_refunded, subscription_payment_success and subscription_payment_refunded, then click "Save webhook".

## Connect Polar

When **Connect Polar** shows, click it, sign in to Polar and allow access: Okidoki adds the webhook to your organization and keeps only its secret. Otherwise:

1. In Polar, open Settings, then Webhooks, and click "Add Endpoint".
2. Choose the format Raw and paste the address in "URL": https://okidoki.sh/api/revenue/rev_...
3. Tick order.paid and order.refunded, then click Create.
4. Copy the secret Polar shows for the endpoint and paste it into Okidoki.

## Connect Paddle

The quickest way: in Paddle, open **Developer tools → Authentication**, create an API key that may write notification settings, and paste it into Okidoki. Okidoki adds the destination for you, without sensitive fields, and does not keep the key. Or by hand:

1. In Paddle, open Developer tools, then Notifications, and click "New destination".
2. Choose Webhook and paste the address in "URL": https://okidoki.sh/api/revenue/rev_...
3. Tick transaction.completed, adjustment.created and adjustment.updated, then click "Save destination".
4. Open the menu next to the new destination, choose "Edit destination", copy the "Secret key" and paste it into Okidoki.

## Connect Squarespace

Squarespace has no webhook for orders, so Okidoki gives you a short piece of code for your order confirmation page instead. Squarespace fills in the order number and total when an order is placed. It needs a Squarespace plan that sells (Business or Commerce).

1. In Squarespace, open Settings, then Advanced, then Code Injection.
2. Paste the code from Okidoki in "Order Confirmation Page" and click Save.
3. Place a test order, or wait for the next one. Okidoki shows Connected when it arrives.

## Connect Wix

When **Connect Wix** shows, click it and add the Okidoki app to your site: it puts the Okidoki tag on every page and counts your paid orders, nothing to copy. Otherwise, Wix tells code on your site when an order is paid. Okidoki gives you a short piece of code that listens for that and sends the order number, total and currency. It needs a premium plan with your own domain, which selling on Wix already does.

1. In Wix, open Settings, then Custom Code, and click "Add Custom Code".
2. Paste the code from Okidoki, name it Okidoki orders, choose "All pages" and "Load code on each new page", and place it in Body - end.
3. Click Apply. Okidoki shows Connected when the next order is paid.

## Connect Klarna Checkout, Svea Checkout or Qliro Checkout

Klarna, Svea and Qliro call your shop's push address for each order, and your shop reads the order there. Send the same order on to Okidoki from your server:

```bash title="From your server, when Klarna, Svea or Qliro calls your push address"
BODY='{"order":"<order id>","total_minor":129900,"currency":"SEK"}'
SIG=$(printf '%s' "$BODY" | openssl dgst -sha256 -hmac "oki_..." | sed 's/^.* //')
curl -X POST https://okidoki.sh/api/revenue/rev_... \
  -H "Content-Type: application/json" \
  -H "X-Okidoki-Signature: sha256=$SIG" \
  -d "$BODY"
```

Sign each request with the secret Okidoki shows next to the address: `X-Okidoki-Signature` is `sha256=` and the hex HMAC-SHA256 of the exact body. Once a signed order has arrived, Okidoki only takes signed ones, so nobody else who finds the address can add or refund orders.

`total_minor` is the total in öre or cents, as Klarna (`order_amount`) and Svea give it. Qliro gives `TotalPrice` in kronor or euros, so send it as `total` instead: `{"order":"<MerchantReference>","total":1299.00,"currency":"SEK"}`. Send `{"order":"<order id>","refunded":true}` to take a fully refunded order off, and `{"test":true}` to check the address. You may add `utm_source`, `utm_medium` and `utm_campaign` if your shop keeps them. No server code? Put the code from Okidoki on your confirmation page instead, with the three fields filled in.

If your shop runs on WooCommerce or Shopify with Klarna, Svea or Qliro inside, connect the shop instead: every order is counted there.

### Klarna

1. When Klarna calls your push address, your server already reads the order from Klarna. Send it on to this address as JSON: https://okidoki.sh/api/revenue/rev_...
2. Send {"order": order_id, "total_minor": order_amount, "currency": purchase_currency}, the same fields Klarna gives you. Send {"order": order_id, "refunded": true} for a full refund.
3. Sign each request: put the header X-Okidoki-Signature: sha256=<HMAC-SHA256 of the exact body, as hex>, made with the secret Okidoki shows here. Once a signed order has arrived, Okidoki only takes signed ones, so nobody else who finds the address can add or refund orders.
4. No server code? Paste the code from Okidoki on your confirmation page instead, with the three Klarna fields filled in.
5. Okidoki shows Connected when the first order or {"test": true} arrives.

### Svea

1. When Svea calls your push address, your server already reads the order from Svea. Send it on to this address as JSON: https://okidoki.sh/api/revenue/rev_...
2. Send {"order": OrderId, "total_minor": the order total in öre or cents, "currency": Currency}. Send {"order": OrderId, "refunded": true} for a full refund.
3. Sign each request: put the header X-Okidoki-Signature: sha256=<HMAC-SHA256 of the exact body, as hex>, made with the secret Okidoki shows here. Once a signed order has arrived, Okidoki only takes signed ones, so nobody else who finds the address can add or refund orders.
4. No server code? Paste the code from Okidoki on your confirmation page instead, with the three fields filled in.
5. Okidoki shows Connected when the first order or {"test": true} arrives.

### Qliro

1. When Qliro calls your MerchantCheckoutStatusPushUrl with the status Completed, your server reads the order from Qliro. Send it on to this address as JSON: https://okidoki.sh/api/revenue/rev_...
2. Send {"order": MerchantReference, "total": TotalPrice, "currency": Currency}, the same fields Qliro gives you. Send {"order": MerchantReference, "refunded": true} for a full refund.
3. Sign each request: put the header X-Okidoki-Signature: sha256=<HMAC-SHA256 of the exact body, as hex>, made with the secret Okidoki shows here. Once a signed order has arrived, Okidoki only takes signed ones, so nobody else who finds the address can add or refund orders.
4. No server code? Paste the code from Okidoki on your confirmation page instead, with the three fields filled in.
5. Okidoki shows Connected when the first order or {"test": true} arrives.

Squarespace, Wix, Klarna, Svea and Qliro do not sign what they send, so the address itself is the secret, just like Gumroad. Make a new one by removing the platform in Okidoki and adding it again.

## Connect Segment

If your site sends Segment's e-commerce events, Segment can send each **Order Completed** call on to Okidoki. Add a mapping with **Send** to the Webhooks (Actions) destination that already sends your page views to Okidoki ([the Segment guide](https://docs.okidoki.sh/install/segment)), with the trigger Event Name is "Order Completed" or "Order Refunded", and the address from Okidoki as **URL**. Okidoki reads `order_id`, `revenue` (or `total`), `currency` and `context.campaign`. Everything else in the call, like `userId`, `anonymousId`, `traits` and the IP address, is thrown away without being stored. Order Refunded or Order Cancelled with the same `order_id` takes the order off.

## Revenue by campaign on Stripe, Lemon Squeezy, Polar and Paddle

These only know where an order came from if your site tells them. Pass the visitor's campaign tags into the checkout when you create it, as `metadata` on Stripe and Polar, `custom_data` on Paddle and checkout custom data on Lemon Squeezy. On Stripe:

```js title="Creating a Checkout session"
const session = await stripe.checkout.sessions.create({
  // ...your line items and URLs
  metadata: { utm_source: 'instagram', utm_medium: 'social', utm_campaign: 'spring-sale' },
});
```

## The revenue report

| Number | What it means |
| --- | --- |
| **Revenue** | Paid orders in the period, minus cancelled ones, compared with the period before |
| **Orders** | How many paid orders |
| **Average order** | Revenue divided by orders |
| **Revenue per visitor** | Revenue divided by visitors, a simple measure of what a visit is worth |

Below the numbers, revenue is split by channel, source and campaign, so you can see which posts and ads actually sell, not just which bring clicks. If orders come in more than one currency, the main currency is shown and the others are listed after it.

## Customers who come back

On Plus, **Customers who come back** shows, for the last 12 months:

- How many first-time customers bought again, and when, month by month.
- Which channels bring the customers who come back most, once at least 5 customers from a channel have had 30 days to return.
- For subscriptions on Stripe, Paddle and Polar: how many still pay after 1, 3 and 6 months. Renewals are not counted as buying again.
- **What a customer is worth**: what customers actually paid in their first 90, 180 and 365 days, per channel they first came from. Only real payments, refunds taken off, never a forecast. Shown from 30 customers.

A customer is the shop's customer number turned into a digest, as above, so this works without ever knowing who anyone is. It starts with the orders that come in after you connect. In the API it is the report `customers`.

## Filters

Revenue can be filtered by where visits came from: source, channel, campaign, UTM source and medium. Filters on page, place or device do not apply, because an order is never linked to a page, a place or a device.

## Good to know

- Cancelled and fully refunded orders are taken off when the platform sends it (on Shopify by hand, add the optional **Order cancellation** webhook).
- Test orders from Gumroad and Lemon Squeezy, and `{"test":true}` sent to a Klarna, Svea or Qliro address, show the platform as connected, but are not counted as revenue.
- Orders already received stay in the report after you disconnect.
- Revenue is never shown through [share links](https://docs.okidoki.sh/share-links).
- Only new orders show up. Orders from before you connected are not imported.

## From the API

```bash
# Start connecting Stripe: gives the webhook address and the steps
curl -X POST https://okidoki.sh/api/v1/sites/mysite.com/revenue \
  -H "Authorization: Bearer oks_..." -H "Content-Type: application/json" \
  -d '{"provider":"stripe"}'

# Finish with the signing secret
curl -X POST https://okidoki.sh/api/v1/sites/mysite.com/revenue \
  -H "Authorization: Bearer oks_..." -H "Content-Type: application/json" \
  -d '{"provider":"stripe","secret":"whsec_..."}'

# Read the report
curl -H "Authorization: Bearer oks_..." "https://okidoki.sh/api/v1/sites/mysite.com/reports/revenue?period=last_month"
```

See the [API reference](https://docs.okidoki.sh/api/reference#revenue).

