> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sideshift.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Install SideShift Pixel

> Install once, connect your consent manager, and capture checkout identity.

Create your website connection first using the [quickstart](/platform/store-attribution). Prefer the exact snippet shown in your setup screen, especially if you use a custom tracking domain. Install one SideShift store pixel per page.

## Install the pixel

Add this script to the `<head>` of each store page. Replace the example values with the values from SideShift.

```html theme={"system"}
<script
  async
  src="https://app.sideshift.app/commerce/pixel.js"
  data-pixel-code="YOUR_PIXEL_CODE"
  data-store-id="YOUR_STORE_ID"
></script>
```

### Consent

The pixel waits for consent before it creates a visitor ID or sends events. Connect it to your consent manager:

```javascript theme={"system"}
// Invoke whenever your consent manager resolves or changes consent.
function updateSideShiftConsent(analyticsAllowed, marketingAllowed) {
  const granted = analyticsAllowed && marketingAllowed;
  window._sideshift = window._sideshift || {};
  window._sideshift.consent = granted; // Also works before the async script loads.
  window.sideshift?.setConsent(granted);
}
```

If your consent manager loads the script only after consent, set `data-consent="granted"` on the script. Do not set it before consent is granted. Revoking consent clears the visitor cookie and stops new events and pending retries.

The pixel automatically records the initial page view after consent. It also records a creator click when the landing URL contains a valid SideShift `ss` parameter. Keep that parameter when redirecting between landing pages.

The pixel observes `pushState`, `replaceState`, and `popstate` in single-page apps. For other routing mechanisms, call `window.sideshift.pageView()` after a route change. A page view is deduplicated by page path for the current document.

### Automatic product views

Add `data-auto-tracking="true"` if your product pages contain `Product` JSON-LD with a `productID` or `sku`. The pixel reads that product data and records the view. Use the manual methods below for cart and checkout events.

If your JSON-LD uses SKU identifiers, use the same identifiers in your order line items. For explicit control, leave automatic tracking off and call `productViewed` yourself.

## Capture identity at checkout

After consent and script readiness, capture identity when creating your checkout:

```javascript theme={"system"}
const visitorId = window.sideshift?.getVisitorId();
const advertising = await window.sideshift?.getAdvertisingContextAsync();
// Attach these to your existing checkout request; persist them with the order.
const attribution = {
  ...(visitorId ? { sideShiftVisitorId: visitorId } : {}),
  ...(advertising ? { sideShiftAdvertising: advertising } : {})
};
```

These values are attribution metadata, not evidence of payment. Your server must obtain amounts, currency, payment time, and refund totals from its trusted order/payment system. Do not generate a replacement visitor ID when consent is absent or tracking is blocked. The custom-store Orders API requires a visitor ID; skip submission through this attribution endpoint when it is missing.

The store-scoped first-party cookie is `ss_vid_YOUR_STORE_ID`, with a lifetime of up to 30 days. The creator attribution window remains seven days. Revoking consent clears the pixel's cookie and stored advertising context and stops its new calls and retries. Apply consent changes to any checkout metadata you persist as well.

## Content Security Policy

Allow the installation origin in `script-src` and `connect-src`. A verified custom domain changes that origin. Managed advertising additionally loads an advertising SDK after consent; see [advertising measurement](/pixel/advertising) for its external domain. Do not weaken your entire CSP with a wildcard to install the pixel.

## Custom tracking domain

In the store's **Tracking** tab, open **Custom tracking domain**. Use a subdomain of the authorized storefront, such as `track.example.com` for `example.com`.

1. Enter the tracking hostname.
2. Add the ownership TXT record shown by SideShift to your DNS provider.
3. Check the connection. SideShift will show the routing and verification records required for that hostname.
4. Add those records and check again until the domain is verified.
5. Copy the updated installation snippet. Its script and browser-event requests use your tracking domain.

Keep the ownership record in DNS. If the domain is pending or has an error, check its DNS records and use the standard installation snippet until it is verified. Before disconnecting the domain, replace any installed snippet that uses it.

SideShift rechecks connected domains in the background. Missing ownership proof or incorrect DNS changes the domain to pending. If verification is more than 48 hours old, the setup screen supplies the standard SideShift hostname until a check succeeds. An installed snippet cannot repair broken DNS by itself; update it if you need to use the standard hostname.

A custom domain can reduce blocking of a third-party tracking hostname. It cannot guarantee delivery or a tracking accuracy percentage. Consent, browser settings, network failures, and blockers can still prevent events. The server order remains necessary to verify a sale.

Custom domains must be enabled for your SideShift deployment. If setup is unavailable, use the standard SideShift pixel hostname.
