> ## 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.

# Install CrispStats on Shopify

> Add the CrispStats script to a Shopify store by pasting the tag above </head> in layout/theme.liquid, then connect the store to record its orders as revenue.

To install CrispStats on Shopify, edit your theme's `layout/theme.liquid` file and paste the script tag just above `</head>`. That file is the main layout of your theme, so one paste covers the storefront pages that use it. To record the store's orders as revenue, [connect Shopify](https://docs.crispstats.com/revenue/shopify.md) in **Settings**, **Integrations** as described below.

## Add the script

**1. Copy the Shopify snippet**

In the CrispStats dashboard, open your site's **Settings**, select **Tracking code** and choose the **Shopify** tab. It has your public key filled in:

```html layout/theme.liquid theme={"theme":{"light":"github-light","dark":"github-dark"}}
<!-- Online Store, Themes, Edit code. Paste above </head>. -->
<script
  defer
  data-site="cs_pk_xxxxxxxx"
  data-domains="example.com"
  src="https://in.crispstats.com/d.js"
></script>
```

**2. Open the theme code editor**

In your Shopify admin, go to **Online Store**, then **Themes**. On your current theme, open the actions menu and choose **Edit code**.

**3. Paste the tag above head**

Under **Layout**, open `theme.liquid`. Find the closing `</head>` tag and paste the script on the line above it:

```html layout/theme.liquid theme={"theme":{"light":"github-light","dark":"github-dark"}}
    <script
      defer
      data-site="cs_pk_xxxxxxxx"
      data-domains="example.com"
      src="https://in.crispstats.com/d.js"
    ></script>
  </head>
```

Save the file.

**4. Open your store**

Open your live storefront in a browser. The status row on the CrispStats **Tracking code** tab shows **Receiving events.** once the first event has been stored.

> [!NOTE]
>
> The tag lives in your theme. If you switch to another theme, or publish a new copy of it, add the tag to that theme's `theme.liquid` too.

## Add optional modules

The switches under **Extra events** on the **Tracking code** tab add attributes to the tag. Copy the updated tag from the **Shopify** tab and replace the one in `theme.liquid`. For example, with outbound links and web vitals on:

```html layout/theme.liquid theme={"theme":{"light":"github-light","dark":"github-dark"}}
<script
  defer
  data-site="cs_pk_xxxxxxxx"
  data-domains="example.com"
  data-outbound
  data-vitals
  src="https://in.crispstats.com/d.js"
></script>
```

## Record revenue from a Shopify store

Connect the store in **Settings**, **Revenue**: choose **Connect a payment provider**, then **Shopify**, and paste the store's myshopify.com address with the Client ID and Client secret of a small app you create for the store in Shopify's Dev Dashboard. CrispStats reads each order back from Shopify's Admin API, so it counts as verified revenue, imports the store's past orders, and records new paid orders and refunds by webhook within seconds, with a check every 15 minutes for anything the webhook missed.

Shopify's checkout pages do not render `theme.liquid`, so the script from this guide does not load there. To tie each order to the visit that led to it, add a short snippet under the CrispStats tag that saves the visitor id on the cart. An order without it is still recorded and counted, without a visit. [Shopify revenue](https://docs.crispstats.com/revenue/shopify.md) walks through both steps.

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

If you sell an app on the Shopify App Store rather than run a store, connect [Shopify App Store](https://docs.crispstats.com/revenue/shopify-app-store.md) instead: it records your app's earnings from Shopify's Partner API.

## Next steps

> [card] [Shopify revenue](https://docs.crispstats.com/revenue/shopify.md)
>
> Connect the store and tie each order to a visit.

> [card] [Revenue overview](https://docs.crispstats.com/revenue/overview.md)
>
> How CrispStats ties a payment to the visit that led to it.

> [card] [Track custom events](https://docs.crispstats.com/track/custom-events.md)
>
> Send add-to-cart and other store actions.


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