Script tag (sz.js)
The measurement half of ShiftZero is one script tag — no bundler, no build step. It works on Shopify themes, WordPress headers, and plain HTML alike.
<script async src="https://YOUR-DASHBOARD/sz.js"
data-endpoint="https://YOUR-COLLECTOR/events?wk=YOUR_WRITE_KEY"
data-consent-cookie="cookie_consent"
data-consent-values="granted"></script>Attributes
| Attribute | Required | Meaning |
|---|---|---|
data-endpoint | yes | Collector events URL. Include your publishable write key as ?wk= — it authenticates ingestion (safe to expose, like a GA measurement id). |
data-consent-cookie | recommended | Name of your consent cookie. Without a granting value present, nothing is measured. |
data-consent-values | optional | Comma-separated cookie values that mean granted (default: 1, true, granted, yes, allow). |
What it does
The tag wraps dataLayer.push and mirrors every event your site already fires — GTM-style objects ({ event: "purchase", value: 42 }) and gtag-style argument arrays both work. Google Analytics keeps receiving everything exactly as before; ShiftZero just listens on the same stream. Each mirrored conversion is stamped with the visitor’s edge assignments (from window.shiftzero, injected by the edge), which makes attribution exact even with several experiments running.
First-party mode (recommended)
When the edge worker or managed proxy is in front of your site, it serves the tag at /sz.js and ingests events at /sz/events on your own domain, forwarding them to the collector with the write key attached server-side. Nothing third-party appears in your page — ad blockers and tracking protections that silently eat competitors’ beacons have nothing to block — and no endpoint or key lives in your HTML:
<script async src="/sz.js" data-endpoint="/sz/events"
data-consent-cookie="cookie_consent"></script>On the managed proxy the tag is even injected automatically — the DNS flip is the entire install.
npm install @shiftzero/track and call createDataLayerBridge({ endpoint, consent }) — same behaviour, typed API, custom event→metric mapping.