# Cedar & Coil: Shopify → Meta conversion tracking guide
**Recommendation:** Use Shopify’s **Facebook & Instagram by Meta** sales channel with **Enhanced** data sharing, if Cedar & Coil’s privacy review permits it. That gives a small DTC store a Meta Pixel and server-side Purchase delivery without a custom backend. Verify both paths in Meta before spending. This is a draft only: nothing was connected, configured, or tested, and there’s no campaign performance baseline.
## 1. Recommended architecture: Pixel + Conversions API
Send eligible website events to **one Meta web dataset**. The **Meta Pixel** records what happens in the browser: product views, successful cart adds, checkout starts, and completed checkouts. It also carries browser and ad-click signals when available. **Conversions API (CAPI)** sends events from the server. For Purchase, the Shopify order record is the source of truth, so the server can report an eligible order even if the browser blocks the Pixel or the confirmation page never loads.
Keep both paths: the Pixel captures storefront activity and browser context; CAPI makes confirmed Purchase delivery less dependent on the browser. When both report the same action, deduplication makes it count once. CAPI does not restore missing click identifiers, bypass consent, or guarantee Meta will attribute an order to an ad.
## 2. Event map and parameters
| Meta standard event | Shopify trigger | What to send |
|---|---|---|
| `ViewContent` | `product_viewed` on the Arc Clip Lamp product detail page | `content_ids` for the viewed product or variant, matching `content_type`, and `value` and `currency` from the displayed price. |
| `AddToCart` | `product_added_to_cart` after Shopify confirms the cart changed—not on button click | `content_ids`, `content_type`, `contents` with item ID and quantity added, `value` of the units added, and `currency`. |
| `InitiateCheckout` | `checkout_started` on actual checkout entry | `content_ids`, `content_type`, `contents` with IDs and quantities, `num_items`, and checkout `value` and `currency`. |
| `Purchase` | Browser: `checkout_completed`. Server: confirmed Shopify order meeting the purchase rule, such as a paid online order if payment defines success. | **Numeric `value`, ISO 4217 `currency`, and `content_ids`**; also send matching `content_type` and `contents` with item IDs and quantities. Never fire on payment-button clicks, failed payments, or a generic thank-you-page load. |
Use the **exact IDs in Meta’s catalog**, including any prefixes and the correct product-versus-variant granularity. Don’t substitute a title, SKU, or raw Shopify ID unless that is the catalog’s actual item ID. For a custom build, define whether Purchase `value` includes tax and shipping, apply discounts consistently, and use the shopper’s transaction currency with the corresponding amount on both paths. For the native channel, inspect what Shopify actually sends and document that convention. The lamp’s listed **$68** price is not an order total or confirmation of the store’s ISO currency code. See [Shopify’s Web Pixels event reference](https://shopify.dev/docs/api/web-pixels-api/standard-events).
## 3. Exactly how deduplication works
For the same action, send the **same case-sensitive event name and event ID to the same dataset**. The Pixel takes `eventID` in the fourth argument; CAPI takes `event_id` on the event object:
```js
fbq('track', 'Purchase', purchaseParams, { eventID: purchaseId });
// CAPI event: { event_name: 'Purchase', event_id: purchaseId, ... }
```
In a custom build, derive `purchaseId` on both sides as `purchase:<stable-shop-key>:<canonical-Shopify-order-id>`. Normalize the Shopify order ID identically if the browser and webhook expose it in different formats. Do not generate separate random IDs in each sender. For earlier events sent on both paths, create one ID per actual occurrence and carry it to the server; two genuine cart adds are two different events.
Meta deduplicates a matching browser/server pair received within **48 hours** of the first event. If only one copy arrives, there’s nothing to deduplicate. If the names, IDs, or datasets differ, both copies can count. Email, amount, and catalog IDs are not substitutes for the event ID. Use server-side idempotency as well: prevent repeat sends for the same order, and reuse the original ID and event time on retries rather than treating a retry as a new purchase.
## 4. Prepare customer information before sending it
- **Normalize, then hash eligible identifiers on the server.** Trim and lowercase email; parse phone using a known country or region, then serialize as country code plus national number, digits only. Hash each normalized value **once** with SHA-256, without a salt, and send the hex digest in the appropriate `user_data` field (`em` or `ph`). Omit blank or invalid fields. If using other permitted identifiers, such as name or postcode, follow Meta’s field-specific rules rather than applying one generic normalizer.
- **Do not hash browser or request signals.** Send genuine `_fbp` and `_fbc` values as `fbp` and `fbc` when available and permitted. Never invent click IDs. Use the shopper’s actual user agent and, if lawfully collected and needed, client IP—not the Shopify webhook’s or your server’s. For website CAPI events, retain the actual event source URL with sensitive query parameters removed.
- **Keep raw customer data and secrets out of logs and browser code.** Hashing helps prepare data for matching; it does not anonymize it. With the native channel, Shopify handles payload preparation; don’t add a second sender to improve matching.
## 5. Shopify setup: native channel versus custom
**Native channel — recommended.** It is free to use on eligible Shopify plans and handles the Pixel, supported server delivery, and browser/server deduplication. The tradeoff is less control over individual payload fields and event-level logs.
1. In **Meta Events Manager → Data Sources**, identify the web dataset owned by the correct business portfolio and confirm the intended ad account can use it. Reuse the right dataset if it already exists.
2. Inventory existing senders before switching anything on: Shopify app and custom pixels, theme code, GTM, tracking apps, and any existing CAPI jobs. Make the native channel the sole owner of the events it sends. Don’t leave an old Purchase sender running in parallel.
3. In Shopify admin, install or open **Sales channels → Facebook & Instagram → Settings → Share data settings**. Enable customer data sharing, select **Enhanced** if approved, and connect the intended Pixel. Shopify describes **Standard** as browser Pixel only, and **Enhanced** and **Maximum** as including Pixel plus CAPI for Purchase. Don’t choose Maximum simply to get CAPI; Enhanced already provides it. Verify the actual Browser/Server coverage in Events Manager rather than assuming all four events are sent server-side.
**Custom implementation — use only for a documented gap**, such as needing control over purchase qualification, payloads, or delivery logs. Use **Shopify Settings → Customer events** and the Web Pixels API for browser events, not legacy checkout Additional Scripts. For server Purchase, use an authenticated Shopify order webhook such as `orders/paid` when payment defines success. Verify Shopify’s webhook signature against the raw body, restrict eligible orders to the online storefront, and store a durable job keyed by shop and order. Join permitted browser context and consent to the checkout or order through a supported, verified correlation key; don’t depend on the Pixel firing to create the order job. If the browser can report checkout completion before payment is confirmed, align the Purchase trigger or use server-only Purchase for that flow. A custom sender means Cedar & Coil owns consent enforcement, mapping, retries, and monitoring.
**Server-side Purchase request sketch — custom path only.** The worker inputs below come from a verified Shopify order and its permitted checkout context. `userData` is already prepared as in §4; `params` contains the actual order `value`, `currency`, `content_ids`, `content_type`, and `contents`.
```js
async function sendPurchase(job) {
// Evaluate the applicable consent/opt-out rules before dispatch and retries.
if (!job.maySendToMeta) return { sent: false, reason: 'privacy gate' };
const { META_GRAPH_VERSION, META_DATASET_ID, META_CAPI_TOKEN } = process.env;
const body = {
data: [{
event_name: 'Purchase',
event_id: job.purchaseId, // Same string as Pixel eventID
event_time: job.occurredAtSeconds, // Original event time, Unix seconds
action_source: 'website',
event_source_url: job.sanitizedEventUrl,
user_data: job.userData, // Hashed em/ph; permitted raw signals
custom_data: job.params
}]
};
if (job.testEventCode) body.test_event_code = job.testEventCode; // Test only
const endpoint =
`https://graph.facebook.com/${META_GRAPH_VERSION}/${META_DATASET_ID}/events`;
const response = await fetch(endpoint, {
method: 'POST',
headers: {
Authorization: `Bearer ${META_CAPI_TOKEN}`,
'Content-Type': 'application/json'
},
body: JSON.stringify(body)
});
const receipt = await response.json();
if (!response.ok || receipt.events_received !== 1) {
throw new Error(`Meta did not acknowledge Purchase (HTTP ${response.status})`);
}
return { sent: true, traceId: receipt.fbtrace_id };
}
```
Pin a supported Graph API version, keep the token in a server secret store, retry transient failures with bounded backoff, and surface permanent failures for review. Log delivery status and trace IDs, not full payloads or credentials. A successful API response is a receipt, not proof of deduplication or ad attribution.
## 6. Validate end to end before scaling spend
1. **Run an approved test checkout with marketing tracking allowed.** Prefer an isolated test dataset and a Shopify test payment flow where supported. Watch the Pixel in browser network tools or Meta Pixel Helper. In **Events Manager → Test Events** for the intended dataset, check all four exact event names and their parameters. For a custom CAPI request, use the dataset’s `test_event_code` in the test payload only. If the native channel doesn’t expose that field or excludes test orders, don’t infer success: arrange an approved test path and confirm server receipt in Events Manager.
2. **Prove one order counts once.** Match the browser and server `Purchase` IDs and confirm Meta shows the pair as deduplicated, not two counted purchases. Compare the value, currency, item IDs, and quantities against the Shopify order and catalog. Check that a failed checkout and a confirmation-page reload don’t add Purchases; for custom CAPI, replay a test webhook and verify it doesn’t create another send.
3. **Test the two failure paths separately.** With marketing tracking allowed, block the Meta browser request and confirm the eligible order still reaches Meta from **Server**. In a fresh session where tracking is declined or opted out under the applicable rules, verify that **neither** path sends an advertising event. Blocking a browser request is not the same test as denying consent.
4. **Check readiness, not just tag firing.** Review Meta **Diagnostics** for missing IDs, deduplication or payload errors, and catalog mismatches. Confirm `Purchase` is selectable for the intended ad account and dataset. After launch, reconcile eligible Shopify orders against Meta event intake over matched time windows. Compare Ads Manager attribution separately: it excludes orders Meta doesn’t credit to ads, and refunds can make Shopify net revenue differ from reported Purchase value.
**Scale gate:** don’t increase spend until Meta receipt, one-order/one-Purchase behavior, order-value accuracy, and privacy behavior have all been verified. Those checks are still pending for this draft.
## 7. Consent and compliance
Configure **Shopify Customer Privacy** or a compatible consent platform for the markets Cedar & Coil serves. Apply the same advertising rules to browser and server delivery: obtain consent where required, honor applicable opt-outs and Global Privacy Control, and don’t treat payment or the existence of an order as permission to share it with Meta. Test that changes in consent also reach the backend and affect queued sends as required. Update the privacy notice to describe Meta sharing and its purposes, minimize data and retention, and review Meta’s terms and applicable local requirements before enabling Enhanced data sharing.