> ## 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 App Store earnings to CrispStats

> Connect the earnings of an app you sell in the Shopify App Store with a Partner API token, your Partner ID and App ID, and link installs to your site's visitors by identifying them with their shop domain.

For developers who sell an app in the Shopify App Store. Connect with a Partner API token, your Partner ID and the app's ID. CrispStats imports the app's past earnings and reads new ones every 10 minutes: subscription charges, one-time charges, usage charges and refunds.

| | |
| - | - |
| You paste | A Partner API token with View financials, your Partner ID and the App ID |
| New payments | Within 10 minutes of Shopify recording the earning |
| History | Every earning of the app |
| Test mode | None: only real earnings are read |
| Linked to a visit | When your site identified the merchant with their myshopify.com domain |

## What is recorded

| Partner transaction | Recorded as |
| - | - |
| App subscription sale | The first sale of a subscription is `subscription_new`, later ones are `subscription_renewal` |
| App one-time sale | `one_time` |
| App usage sale | `subscription_renewal` of the subscription it is billed on |
| A sale adjustment or credit that takes money back | `refund` of the charge's sale. One that cannot be matched to a sale CrispStats counted is not counted |

The amount is what the merchant paid, before tax, in its own currency. Every earning is read from Shopify's Partner API with your token, so each one is verified.

## Connect Shopify App Store

**1. Open the panel**

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

**2. Create the Partner API token**

Under **Shopify Partner API token**, select **Create a Partner API token**. It opens the Shopify Dev Dashboard. Then:

1. Open **Organization settings**, then **Users**, then **Security**, and choose **Add Partner API client**.
2. Name it CrispStats and tick **View financials** only.
3. Choose **Add client** and copy the access token here. Shopify shows it once.

**3. Enter the Partner ID and App ID**

Open your app in the Partner Dashboard. Both IDs are in the address: `partners.shopify.com/<Partner ID>/apps/<App ID>`. Paste them into **Partner ID** and **App ID**.

Use the numbers from `partners.shopify.com`, not the Dev Dashboard's organization number: the panel refuses a value from a `dev.shopify.com` address.

**4. Connect**

CrispStats checks the token against the app at once. Select **Connect Shopify App Store**. The row shows **Connected to** your app.

| Message | What to do |
| - | - |
| Shopify did not accept this token. Copy it again in one piece, or create a new Partner API client. | Shopify shows a token once, so create a new client if you no longer have it. |
| This token cannot read earnings. Edit the API client and tick View financials. | Tick **View financials** on the client. |
| No app with that ID in the Partner organization. | Check both IDs in the address of your app's page. |

## What the token can do

**View financials** is read-only and covers your organization's app and theme earnings. It is the only permission that reads money actually paid. CrispStats does not ask for **Manage apps**: it gives app events such as installs and charges activated, which are not payments. CrispStats never moves money.

## How fresh the numbers are

Shopify sends no webhooks for earnings, so CrispStats reads new transactions every 10 minutes. An earning appears within 10 minutes of Shopify recording it. Shopify records an earning when the merchant is billed, not when they install.

## Past payments

When you connect, CrispStats imports every transaction of the app. See [revenue history](https://docs.crispstats.com/revenue/history.md).

## Test mode

Charges on development stores are test charges. As far as Shopify's documentation shows, they never become earnings, so nothing test is read. This has not been confirmed with a real Partner account; if a test charge ever appears, report it to support.

## Link earnings to visits

A merchant installs your app from the Shopify App Store, not from a checkout on your site, so no visitor id travels with the charge. CrispStats links an earning to your site's visitors through the merchant's shop domain instead: call `crispstats.identify()` with the merchant's `myshopify.com` domain when they sign in on your site, for example in your app's onboarding or on your marketing site after OAuth:

```js theme={"theme":{"light":"github-light","dark":"github-dark"}}
// When you know which shop the visitor manages
crispstats.identify("their-store.myshopify.com");
```

Use the domain in lower case, without `https://`. Each earning carries the shop's domain as its user id, so it is credited to that user's first visit. Earnings from shops your site never identified are recorded and counted, without a visit.

## Disconnect

Select **Disconnect** on the row. CrispStats stops reading earnings and destroys the saved token. Payments already recorded stay. CrispStats created nothing in your Partner organization. You can delete the Partner API client in the Dev Dashboard.

## Next steps

> [card] [Identify users](https://docs.crispstats.com/track/identify-users.md)
>
> Tie visits to the shop domain with `crispstats.identify()`.

> [card] [Shopify store](https://docs.crispstats.com/revenue/shopify.md)
>
> Run a store? Connect its orders 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.