---
title: "Install DataPocket on Shopify"
description: "Add DataPocket web analytics with revenue attribution to Shopify. Theme snippet for the storefront, plus a custom pixel for checkout and verified order revenue."
url: "https://datapocket.vo1d.studio/docs/shopify"
lang: "en"
updated: "2026-11-13"
---

# Install DataPocket on Shopify

Theme snippet for the storefront, plus a custom pixel for checkout and verified order revenue. Replace `YOUR_SITE_ID` and `YOUR_DOMAIN` with the values from your site's Install page.

## Steps

1. Online Store → Themes → … → Edit code → layout/theme.liquid. Paste right before </head>:

```liquid
<script
  defer
  data-site-id="YOUR_SITE_ID"
  data-domain="YOUR_DOMAIN"
  src="https://datapocket.vo1d.studio/js/script.js"
></script>
```

2. Settings → Customer events → Add custom pixel "DataPocket". Paste and Connect. This tracks checkout steps and the completed order:

```js
const PD = "https://datapocket.vo1d.studio/api/event", SITE = "YOUR_SITE_ID", DOMAIN = "YOUR_DOMAIN";

async function send(type, href, extraData) {
  const [vid, sid] = await Promise.all([browser.cookie.get("dp_vid"), browser.cookie.get("dp_sid")]);
  if (!vid) return;
  fetch(PD, { method: "POST", keepalive: true, headers: { "Content-Type": "text/plain" },
    body: JSON.stringify({ type, siteId: SITE, domain: DOMAIN, href, referrer: null, visitorId: vid, sessionId: sid || "s" + vid, extraData }) });
}
analytics.subscribe("checkout_started", (e) => send("custom", e.context.document.location.href, { eventName: "checkout_started" }));
analytics.subscribe("checkout_completed", (e) => {
  const c = e.data.checkout;
  send("payment", e.context.document.location.href, { shopify_order_id: String(c.order?.id ?? ""), amount: String(c.totalPrice?.amount ?? ""), currency: c.currencyCode });
});
```

## Revenue attribution

1. Settings → Revenue → Shopify: enter your store domain and an Admin API token (custom app with read_orders). Orders reported by the pixel are verified against Shopify before they count as revenue, and refunds sync via webhook.

## Verify

1. Deploy or publish, then open your site in a normal browser window (ad blockers off).
2. In the browser's Network tab, look for a POST to `/api/event` (or `/dp/api/event` when proxied) that returns `{"ok":true}`.
3. The DataPocket Install page for this site switches to "Receiving data" within a few seconds.

## Related guides

- [Wix](https://datapocket.vo1d.studio/docs/wix): Settings → Custom Code (needs a Premium plan and a connected domain).
- [Webflow](https://datapocket.vo1d.studio/docs/webflow): Site Settings → Custom Code → Head code (paid site plan).
- [Bubble](https://datapocket.vo1d.studio/docs/bubble): Settings → SEO/metatags → Script/meta tags in header (paid plan).
- [Squarespace](https://datapocket.vo1d.studio/docs/squarespace): Settings → Advanced → Code Injection → Header (Core plan or higher).
- [AI crawler tracking](https://datapocket.vo1d.studio/docs/ai-bots)
