# Shopify analytics with CrispStats

Updated 2026-11-24

To add CrispStats to a Shopify store, paste the script tag above the closing head tag in your theme's layout/theme.liquid file. That covers the storefront pages. Then connect the store in **Settings**, **Integrations** with the client ID and secret of a small app you create for it, and every paid order and refund counts as verified revenue, tied to the visit that led to it.

## Steps

### 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 and your store's domain filled in.

### 2. Open the theme code editor

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

### 3. Paste the tag above the closing head tag

Under **Layout**, open `theme.liquid`. Find `</head>` and paste the script on the line above it, then save the file.

`layout/theme.liquid`

```html
    <script
      defer
      data-site="cs_pk_your_site_key"
      data-domains="example.com"
      src="https://in.crispstats.com/d.js"
    ></script>
  </head>
```

### 4. Tag store actions (optional)

Add `data-cs-event` to a button in your theme templates to count it as a custom event, with properties from `data-cs-prop-` attributes. No JavaScript is needed.

```html
<button data-cs-event="add to cart" data-cs-prop-sku="tee-01">
  Add to cart
</button>
```

### 5. Connect the store

In **Settings**, **Integrations**, choose **Connect a payment provider**, then **Shopify**. Enter the store's myshopify.com address, create an app for the store in Shopify's Dev Dashboard with `read_orders` and `read_all_orders`, install it, and paste its **Client ID** and **Client secret**. CrispStats imports past orders and creates its own webhooks for paid orders and refunds. See [Shopify revenue](/docs/revenue/shopify) for each step.

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

The script does not run on Shopify's checkout pages, so the visitor id travels on the cart. Paste this below the script tag in `theme.liquid`. It does nothing when the visitor declined analytics in your store's cookie banner.

`layout/theme.liquid`

```liquid
{% 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 %}
```

## Check that it works

Open your live storefront in a browser. The status row on the CrispStats **Tracking code** tab shows **Receiving events.** once the first event is stored, and the visit appears on the **Realtime** screen within a few seconds. Once the store is connected, a paid order appears under **Payments** on the Revenue screen with the source of that visit.

## What you get

- Visitors, pageviews and sessions for the storefront pages that use `theme.liquid`: home, collections, products, cart and content pages.
- Which channels bring shoppers: search, social, email and ad campaigns tagged with UTM parameters, and AI assistants such as ChatGPT and Perplexity.
- Funnels from a product page to the cart, built from page paths or your own events, calculated over data you already have.
- Revenue per source and campaign for every paid order, read back from Shopify's Admin API so it counts as verified, credited to the first touch known for the visitor, with refunds as negative payments.
- Countries, devices and browsers, with no cookies and no IP addresses stored.

## Notes for Shopify

- Shopify sends each paid order within seconds, and CrispStats checks every 15 minutes for anything the webhook missed. With `read_all_orders` the import reads every order since your first, otherwise the last 60 days.
- Shopify's checkout and order status pages do not use `theme.liquid`, so the script does not run there. The cart attribute carries the visitor id into the order instead.
- Shopify does not mark renewal orders, so every order is recorded as a one-time payment. Test orders show with a **Test** tag and are kept out of revenue and every total.
- An order without the cart attribute is still recorded and counted, without a visit: it is left out of the source and campaign breakdowns.
- If you report Shopify orders yourself through the payment API, stop when you connect Shopify. Those payments are stored under a different provider, so each order would count twice.
- The tag lives in one theme. If you switch themes, or publish a new copy of the theme, add the tag and the cart snippet to that theme's `theme.liquid` too.
- There are no product-level ecommerce reports: no inventory, margins or product performance. Shopify stays the source of truth for orders.

Full reference: [Shopify in the docs](https://docs.crispstats.com/install/shopify)

## Frequently asked questions

### Is there a Shopify app for this?

There is no app to install from the Shopify App Store. CrispStats is one script tag in your theme, and you connect the store's orders with the client ID and secret of a small app you create for your own store in Shopify's Dev Dashboard.

### Can it track the Shopify checkout?

The script does not load there, because Shopify's checkout and order status pages do not render theme.liquid. The order still reaches the Revenue screen through the connected store, tied to the visit by the visitor id saved on the cart.

### Does it replace Shopify's own analytics?

No. It answers a different question: which sources, campaigns and pages bring the visitors who buy. Keep Shopify for orders, inventory and product reports, which this does not have.

### Does Shopify analytics with this need a cookie banner?

CrispStats sets no cookies and stores nothing on the shopper's device by default. Shopify itself sets cookies for the cart and checkout, and apps you install may add more, so the answer depends on the whole store. This is not legal advice.

### What does it cost for a store?

Every feature is on every plan. Every account starts with a 14-day free trial with no card. Starter is $5 a month for 250,000 events and Growth is $12 for 1,000,000.

## Related

- [Cookieless analytics for online stores](/for/ecommerce)
- [Revenue attribution: which traffic pays](/features/revenue-attribution)
- [Funnels and goals](/features/funnels)
- [Revenue per visitor calculator](/tools/revenue-per-visitor-calculator)
