You are helping integrate LinkJolt affiliate tracking into a Squarespace Commerce store.

## Context
- Merchant ID: YOUR_MERCHANT_ID
- Platform: Squarespace Commerce (NOT Stripe Checkout — Squarespace uses its own checkout with Stripe as the processor)
- Tracking Script: https://www.linkjolt.io/api/tracking.js?id=YOUR_MERCHANT_ID
- Required plan: Squarespace Business / Core plan or higher (Personal plan does not support Code Injection).

Squarespace Commerce DOES NOT fire `checkout.session.completed`. Attribution runs entirely through the browser-side `window.linkjolt.trackPurchase()` call on the Order Status Page.

## Setup

In Squarespace Admin → Settings → Advanced → Code Injection:

### Header slot (fires on every page)
```html
<script src="https://www.linkjolt.io/api/tracking.js?id=YOUR_MERCHANT_ID" async></script>
```

### Order Status Page slot (for physical / digital / service products)
```html
{.if firstPageView}
<script>
if (window.linkjolt && window.linkjolt.isAffiliateVisit()) {
  window.linkjolt.trackPurchase(
    {orderSubtotalCents}/100,
    { orderId: '{orderId}' }
  );
}
</script>
{.end}
```

The `{.if firstPageView}...{.end}` wrapper is MANDATORY — Squarespace's Order Status Page fires every time the customer revisits it, which would otherwise double-count conversions.

### Order Confirmation Page slot (ONLY if store sells gift cards / memberships / subscriptions)

Same snippet as Order Status Page, but WITHOUT the `{.if firstPageView}` wrapper (Order Confirmation Page fires once per purchase for these product types).

## Available template variables (in both order slots)

`{orderId}`, `{orderSubtotal}`, `{orderSubtotalCents}`, `{orderGrandTotal}`, `{orderGrandTotalCents}`, `{customerEmailAddress}`.

## Common issues

- "0 conversions after clicks" → snippet is in the wrong slot. Physical-product stores must use **Order Status Page** (not Order Confirmation Page).
- "Conversions firing twice" → missing `{.if firstPageView}` wrapper on Order Status Page.
- "Amount is 100× too big" → using `{orderSubtotalCents}` directly without dividing by 100.
- "Plan not supporting Code Injection" → merchant needs to upgrade to Business / Core.
