Setup & Docs
Everything you installed in Shopify, and how it works.
❌Webhooks reachable
loading…
❌HMAC verifying
loading…
❌CAPI sending
loading…
❌EMQ Purchase ≥ 7.5
no EMQ pull yet
Hygiene checklist
- Shopify Admin → Online Store → Preferences → Customer Privacy
- Shopify → Sales channels → Facebook & Instagram → Settings → Data sharing = Maximum
- Shopify → Online Store → Preferences → Customer Privacy → Set first-party cookie duration to 365 days
- Run Pixel Helper on the live site — exactly one PageView should fire.
- Shopify → Settings → Customer accounts → Classic. New customer accounts break attribution.
Full-funnel Meta Pixel
Paste this single script as a Custom Pixelin Shopify Admin → Customer events. It forwards the full Meta funnel (PageView, ViewContent, Search, AddToCart, InitiateCheckout, AddPaymentInfo) to the cockpit's CAPI server, persistsfbclid/fbp/fbc, and hashes email + phone on checkout_started so the orders/create webhook receives them in note_attributes.
Purchase + Delivered events are notsent from the browser — the cockpit's server-side CAPI fires those from the orders/create + fulfillment webhooks (single source of truth).
Webhook subscriptions
- Order creation
/api/webhooks/shopify/orders/create - Order update
/api/webhooks/shopify/orders/updated - Order cancellation
/api/webhooks/shopify/orders/cancelled - Order fulfilled
/api/webhooks/shopify/orders/fulfilled - Refund creation
/api/webhooks/shopify/refunds/create - Fulfillment creation
/api/webhooks/shopify/fulfillments/create - Fulfillment update
/api/webhooks/shopify/fulfillments/update - Product creation
/api/webhooks/shopify/products/create - Product update
/api/webhooks/shopify/products/update - Product deletion
/api/webhooks/shopify/products/delete - Inventory item update (cost per item)
/api/webhooks/shopify/inventory-items/update
Each webhook uses Format: JSON · API version 2025-04 · the sameSHOPIFY_WEBHOOK_SECRETfor HMAC verification.
Shopify API setup (client_credentials flow)
- Shopify Admin → Settings → Apps and sales channels → Develop apps → Create an app. Name it
MTS Cockpit. - In the new app: Configuration → Admin API access scopes. Grant
read_orders,read_products,read_inventory,read_fulfillments,read_customers. - Install the app, then go to API credentials and copy the Client ID and Client secret (starts with
shpss_). Put them in.envasSHOPIFY_CLIENT_IDandSHOPIFY_CLIENT_SECRET. - The cockpit exchanges those for a short-lived
shpat_…access token at request time — no long-lived token storage needed. If a 401 happens, the cockpit re-exchanges automatically. - Run
POST /api/jobs/shopify_products_sync/runfrom /jobs to confirm the credentials work.
Verify everything is firing
EMQ check: Open Meta Events Manager → Data Sources → your pixel → Overview. Look for Event Match Quality ≥ 7.5 on the Purchase event. Open Events Manager
CAPI test: Set
FB_CAPI_TEST_EVENT_CODE in your .env (find it in Events Manager → Test Events), fire a test order, and watch it appear in real-time on the Test Events tab. Real CAPI activity also surfaces at /attribution.Architecture: See
ATTRIBUTION-PLAN.mdin the project root for the full pixel ↔ webhook ↔ CAPI ↔ P&L flow diagram.