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

> ## Agent Instructions
> CrispStats is a hosted, privacy-first web analytics product. It has no self-hosted edition, no session replay, no heatmaps, no A/B testing, no mobile SDKs and no data import except a site's history from a Plausible export (Settings, Import and export).
> The script global is crispstats(...), site keys start with cs_pk_ and secret API keys start with cs_sk_. The script is served from https://in.crispstats.com/d.js and the REST API lives at https://crispstats.com/api/v1.
> There is no npm package to install. Integrations copy the script tag, the queue stub, crispstats.d.ts and proxy code from these docs or from Settings, Tracking code in the dashboard. A first-party proxy forwards one path of the site to https://in.crispstats.com/p/ and forwards only content-type, user-agent, accept-language, referer, origin, if-none-match and x-forwarded-for, never cookies.

# Connect Shopify revenue to CrispStats

> Connect a Shopify store with the client ID and secret of an app you create in your Dev Dashboard: CrispStats imports past orders, records new ones and ties each to a visit through a cart attribute.

Connect a Shopify store with the client ID and secret of a small app you create for it in Shopify's Dev Dashboard. CrispStats imports the store's past orders, creates its own webhooks, and records paid orders and refunds from then on. Save the visitor id on the cart and each order is tied to the visit that led to it.

| | |
| - | - |
| You paste | The store's myshopify.com address, and the Client ID and Client secret of an app installed on it |
| New payments | Within seconds, by webhook. A check every 15 minutes catches anything the webhook missed |
| History | Every order since your first with `read_all_orders`, otherwise the last 60 days |
| Test mode | Per order: test orders show with a **Test** tag |
| Linked to a visit | When the cart carries the visitor id as a cart attribute |

## What is recorded

| Shopify object | Recorded as |
| - | - |
| A paid order | `one_time`, for the total the buyer paid in their own currency. Shopify does not say which orders are subscription renewals, so every order is `one_time` |
| A refund | `refund` of its order, for the amount refunded |

Every order is read back from Shopify's Admin API with your app's credentials before it counts as verified revenue. The product is the first line item's title. Chargebacks are not read from Shopify; refunds you make in Shopify are.

## Connect Shopify

You need to own the store, or be allowed to create apps for it.

**1. Open the Shopify panel**

In CrispStats, open the site's **Settings**, then **Integrations**. Select **Connect a payment provider** and choose **Shopify**.

**2. Enter the store address**

Under **Store address**, enter the store's `your-store.myshopify.com` address. You find it in Shopify's **Settings**, then **Domains**. A custom domain is refused: use the myshopify.com one. Pasting the store's admin address works too.

**3. Create the app in the Dev Dashboard**

Under **Client ID**, select **Create an app in the Shopify Dev Dashboard**. Then:

1. Choose **Create app** and name it CrispStats.
2. In a new version, add the scopes `read_orders` and `read_all_orders`.
3. In the same version, under **Protected customer data**, select **Orders**, then release the version.
4. Choose **Install app** and pick this store.
5. Open **Settings** and copy the **Client ID** and **Client secret** here.

**4. Paste the Client ID and secret**

Paste them into **Client ID** and **Client secret**. CrispStats asks Shopify for a token for this store at once and reads the store's name.

**5. Connect**

Select **Connect Shopify**. CrispStats creates webhooks for paid orders, refunds and uninstalling, and the row shows **Connected to** your store. **Live.**

**6. Save the visitor id on the cart**

See [pass the visitor id at checkout](#pass-the-visitor-id-at-checkout) below.

### If Shopify refuses

| Message | What to do |
| - | - |
| Shopify did not accept this client ID and secret. Check both are from the app installed on this store. | Copy both again from the app's **Settings** in the Dev Dashboard. |
| The app is not installed on this store, or the store is not in the same Shopify organization as the app. | Install the app on the store from the Dev Dashboard. |
| Shopify would not give CrispStats access to this store. | Open the Dev Dashboard from this store's admin (**Settings**, **Apps**, **Develop apps**), create the app there, install it on this store, and copy the Client ID again. |
| The app is missing `read_orders`. | Add it in a new version and release it. |

Shopify gives this kind of app access only to stores in the same Shopify organization as the app. Owning a store does not always place it in the organization you are signed in to, which is why creating the app from the store's own admin is the safest route.

> [!NOTE]
>
> Shopify stopped letting merchants create apps inside the store admin on 1 January 2026. Apps are now made in the Dev Dashboard, and an app made there for your own organization's store needs no review from Shopify for `read_all_orders` or for order data.

## What the app can do

| Scope | Why |
| - | - |
| `read_orders` | Read and verify orders and refunds |
| `read_all_orders` | Read orders older than 60 days, for the import. Without it CrispStats imports only the last 60 days, and the row says so |
| Protected customer data: Orders | Without it Shopify hides parts of each order. CrispStats reads no customer names or addresses |

The app has no write scopes, so it cannot change products, orders or refunds. CrispStats never moves money. It keeps the client secret encrypted and asks Shopify for a fresh token when it needs one; the token lasts a day and is never stored.

## How fresh the numbers are

Shopify sends each paid order and refund within seconds, and CrispStats checks for updated orders every 15 minutes as a safety net. An order seen both ways is stored once. Shopify removes webhooks after repeated failed deliveries; the row then asks you to disconnect and connect again.

## Past payments

When you connect, CrispStats imports the store's orders and refunds: all of them with `read_all_orders`, the last 60 days without it. See [revenue history](https://docs.crispstats.com/revenue/history.md).

## Test mode

Shopify marks orders placed with the Bogus Gateway or a payment provider's test mode as test orders. They show with a **Test** tag and never count as verified revenue. The app itself has no test or live mode.

## Pass the visitor id at checkout

The CrispStats script does not run on Shopify's checkout pages, so the visitor id travels on the cart. In **Online Store**, **Themes**, **Edit code**, open `layout/theme.liquid` and paste this below the CrispStats tag, above `</head>`:

```liquid layout/theme.liquid theme={"theme":{"light":"github-light","dark":"github-dark"}}
{% if cart.item_count > 0 %}
  <script>
    window.addEventListener("load", async function () {
      var privacy = window.Shopify && window.Shopify.customerPrivacy;
      if (privacy && privacy.analyticsProcessingAllowed && !privacy.analyticsProcessingAllowed()) return;
      var id = await window.crispstats?.id();
      if (!id) return;
      fetch(window.Shopify.routes.root + "cart/update.js", {
        method: "POST",
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify({ attributes: { __crispstats_vid: id } }),
      });
    });
  </script>
{% endif %}
```

On every storefront page with items in the cart, this saves the visitor id of the current visit on the cart. It does nothing when the visitor declined analytics in your store's cookie banner, so those orders stay unlinked. Shopify hides attributes whose name starts with two underscores from the buyer and keeps them on the order, where CrispStats reads them. An attribute named `crispstats_visitor_id` is read too, so a snippet you added earlier keeps working.

To check it: with an item in the cart, open `/cart.js` on your store. `attributes` should hold `__crispstats_vid` with 32 hexadecimal characters. If it is missing, check that the CrispStats script loads on the page; an ad blocker can stop it. See [install on Shopify](https://docs.crispstats.com/install/shopify.md).

An order without the attribute is still recorded and counted, without a visit.

> [!WARNING]
>
> If you report Shopify orders yourself through the [payment API](https://docs.crispstats.com/revenue/payment-api.md), for example from an Order payment webhook on your own server, stop doing so when you connect Shopify. Those payments are stored under a different provider, so each order would count twice.

## Disconnect

Select **Disconnect** on the Shopify row. CrispStats removes its webhooks from the store and destroys the saved client secret. Payments already recorded stay. If Shopify does not let CrispStats remove them, uninstall the app from the store in **Settings**, then **Apps**, which removes them too. You can then delete the app in the Dev Dashboard.

## Next steps

> [card] [Install on Shopify](https://docs.crispstats.com/install/shopify.md)
>
> The script tag in `theme.liquid`.

> [card] [Shopify App Store](https://docs.crispstats.com/revenue/shopify-app-store.md)
>
> Sell an app on Shopify? Connect its earnings instead.

> [card] [Revenue history](https://docs.crispstats.com/revenue/history.md)
>
> What the import reads and how it avoids counting twice.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.