# Cedar & Coil: Shopify → Meta conversion tracking guide
**Recommendation:** Use Shopify’s **Facebook & Instagram by Meta** sales channel to send browser Pixel and server-side Conversions API events to the same Meta dataset. For a small DTC store, start with the native integration and build a custom sender only if testing reveals a specific gap. This is a draft implementation guide: nothing was configured or sent, and no event delivery has been verified.
## 1. Recommended architecture
- **Browser — Meta Pixel:** Captures product views, cart additions, checkout starts, and completed checkouts in context. Where permitted and available, it also carries browser and ad-click identifiers that help Meta match events.
- **Server — Meta Conversions API (CAPI):** Sends events from Shopify’s integration or your backend. For a custom `Purchase`, use Shopify’s authoritative order/payment record rather than relying on the confirmation page loading. A server event can still arrive when a browser tag is blocked, but it cannot recreate missing click identifiers or override a privacy choice.
- **Same dataset, shared event ID:** When both paths report the same action, Meta should count it once. Use one implementation owner for each event; don’t layer a custom sender over native tracking for the same purchase.
## 2. Standard events and parameters
| Meta event | When to send | Key parameters |
|---|---|---|
| `ViewContent` | Arc Clip Lamp product detail page is viewed | `content_ids` matching the Meta catalog; `content_type`; `value` as displayed item price; `currency` as the checkout/storefront currency code |
| `AddToCart` | Shopify confirms the item was added, not on button click | `content_ids`; `content_type`; `contents` with item ID and quantity added; `value` for the items added, not the whole cart; `currency` |
| `InitiateCheckout` | The shopper actually enters checkout | `content_ids`; `content_type`; `contents` with IDs and quantities; `num_items`; `value` from the checkout subtotal under the chosen definition; `currency` |
| `Purchase` | A real order meets the store’s purchase criterion; for a custom build, use confirmed payment | **`value`** from the actual order, **`currency`** from the same amount’s ISO 4217 currency code, and **`content_ids`** matching the catalog; also send `content_type` and `contents` with IDs and quantities |
Inspect the synced catalog before mapping IDs. Don’t assume that a Shopify SKU, product ID, or variant ID is what Meta ingested. Use `content_type: "product"` for item IDs or `"product_group"` for group IDs, consistent with the catalog. Use numeric amounts in major currency units and keep amount and currency on the same basis, especially for multi-currency orders.
For a custom build, a practical purchase-value convention is the paid order total after discounts, including tax and shipping. With the native channel, verify what it actually sends and use that same basis when reconciling. The supplied **$68** is the Arc Clip Lamp’s listed price, not a hard-coded purchase value; the fixture does not specify an ISO currency code.
## 3. Exactly how deduplication works
For the same action, send the **same case-sensitive event name and exact ID to the same Pixel/dataset**. Pixel takes `eventID` in its options argument; CAPI takes `event_id` on the event object, not in `custom_data`.
```js
// Custom browser path only. Use the same canonical order ID on the server.
fbq("track", "Purchase", purchaseParams, {
eventID: `purchase:${canonicalShopifyOrderId}`
});
```
Both copies should arrive promptly, within Meta’s **48-hour deduplication window**. The ID identifies one occurrence, not a shopper or session. For a purchase, derive it from the same canonical order ID on both paths; normalize Shopify’s numeric and global ID representations if the browser and backend expose different formats. Reuse the ID on retries. Persist server delivery state and guard the browser event against confirmation-page reloads. For repeatable actions like adding to cart, use a fresh ID for each actual addition and share it only with that action’s server counterpart.
Email hashes, `_fbp`, and `_fbc` help with **matching**; they are not a substitute for an explicit shared event ID. Deduplication also doesn’t fix a browser `Purchase` fired for an unpaid order. If the browser cannot verify the same success criterion as the backend, send that purchase server-side only.
## 4. Prepare customer information before sending
- Apply the applicable advertising data-sharing permission first. Send only permitted, necessary fields in CAPI’s `user_data`. Leave absent fields out; never hash empty strings or invent identifiers.
- Normalize email by trimming and lowercasing it. Normalize phone to digits only, including its verified country calling code; don’t guess the country. SHA-256 hash these normalized values once, server-side, and send the lowercase hex digests. For any additional matching fields, follow Meta’s field-specific normalization and hashing rules.
- **Do not hash** permitted `fbp`, `fbc`, `client_ip_address`, or `client_user_agent`. Send them only when actually captured from the customer’s browser or request. Never use the webhook sender’s IP or user agent, and never fabricate an `fbc` without a real Meta click identifier.
- Keep the access token in a server-side secret store. Redact tokens, raw customer data, and match identifiers from logs. Avoid sending checkout tokens or personal information in `event_source_url`.
## 5. Shopify setup: native first, custom only for a verified gap
**Native path:** In Shopify Admin, open **Sales channels → Facebook & Instagram by Meta → Settings → Data sharing settings**. Add the official channel if it isn’t already installed. Select the correct Meta business assets and confirm the dataset is the one the ad account will use. Enable sharing and choose **Maximum** for the intended Pixel + CAPI setup **only after** confirming it fits the store’s privacy requirements. Verify the synced catalog and check Shopify **Settings → Customer events**, theme code, tag managers, and other apps for existing Meta senders. If replacing one, plan the cutover so two implementations don’t report the same events. Menu labels and asset permissions should be confirmed in the actual account.
**Custom path:** Use Shopify Customer Events/Web Pixels for supported browser ecommerce events, not legacy checkout scripts. Use a verified Shopify `orders/paid` webhook for the backend purchase signal. Verify Shopify’s signature against the raw request body, persist the event to a durable queue, and enforce order-level idempotency. If both paths send `Purchase`, they must use the same verified success condition and order-derived ID. Custom code gives you control over event timing, value mapping, logs, and retries, but you own consent propagation, checkout compatibility, and maintenance. Don’t run the sketch below alongside the native `Purchase` sender.
**Server-side `Purchase` sketch (custom alternative, Node.js):**
```js
import { createHash } from "node:crypto";
const sha256 = value =>
createHash("sha256").update(value, "utf8").digest("hex");
// Called by a worker after webhook signature verification and durable enqueue.
// order is a validated internal record, not the raw Shopify webhook payload.
async function sendMetaPurchase(order, match, testEventCode) {
if (!order.isPaid || !order.metaSharingAllowed) return;
const email = match.email?.trim().toLowerCase();
const phone = match.phoneWithVerifiedCountryCode?.replace(/\D/g, "");
const user_data = {
...(email && { em: [sha256(email)] }),
...(phone && { ph: [sha256(phone)] }),
...(match.fbp && { fbp: match.fbp }),
...(match.fbc && { fbc: match.fbc }),
...(match.clientIp && { client_ip_address: match.clientIp }),
...(match.userAgent && { client_user_agent: match.userAgent })
};
// Don't fabricate match data. Surface a no-match-data skip in worker metrics.
if (!Object.keys(user_data).length) return { skipped: "no_match_data" };
const payload = {
data: [{
event_name: "Purchase",
event_time: Math.floor(order.paidAtMs / 1000),
event_id: `purchase:${order.canonicalId}`,
action_source: "website",
event_source_url: order.sanitizedCustomerCheckoutUrl,
user_data,
custom_data: {
value: order.paidTotalMajorUnits,
currency: order.paidCurrency,
content_type: "product", // Assumes IDs below are catalog item IDs.
content_ids: order.items.map(item => item.metaCatalogId),
contents: order.items.map(item => ({
id: item.metaCatalogId,
quantity: item.quantity
}))
}
}],
...(testEventCode && { test_event_code: testEventCode })
};
const { META_GRAPH_VERSION, META_PIXEL_ID, META_CAPI_TOKEN } = process.env;
const url = new URL(
`https://graph.facebook.com/${META_GRAPH_VERSION}/${META_PIXEL_ID}/events`
);
url.searchParams.set("access_token", META_CAPI_TOKEN);
const response = await fetch(url, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(payload),
signal: AbortSignal.timeout(10_000)
});
const result = await response.json();
// Worker: persist accepted delivery; selectively retry transient failures
// (network errors, 429, 5xx) with backoff and the original ID and timestamp.
// Route permanent errors to review. Never log the request URL or payload.
return {
accepted: response.ok && result.events_received === 1,
status: response.status,
metaErrorCode: result.error?.code,
traceId: result.fbtrace_id
};
}
```
Use a supported Graph API version. Before enqueueing, validate the currency, numeric total, payment timestamp, and catalog mapping. Recheck current sharing eligibility before sending a queued event. An API acceptance receipt confirms intake, not successful matching, deduplication, or ad attribution.
## 6. Validate end to end before scaling spend
1. **Run an authorized test checkout** using Shopify’s test payment flow or a designated test store/dataset. In Meta **Events Manager → Test Events**, verify the consented journey: view the lamp, add it to cart, enter checkout, and complete payment. For the custom CAPI path, use the dataset’s `test_event_code`. If native server events don’t appear in Test Events, check the dataset’s event activity for the **Server** connection method and correlate it to the controlled test; Pixel Helper alone cannot verify server receipt.
2. **Verify one logical purchase.** Inspect the browser and server copies where visible. For custom sends, compare the exact event name and ID, then check Meta’s deduplication diagnostics. Reconcile the amount, currency, catalog IDs, and quantities against the Shopify order and Meta catalog.
3. **Test failure cases.** An abandoned or failed checkout must not count as a purchase. Reloading the confirmation page or replaying a webhook must not create a second purchase. For a consented test with the browser tag blocked, confirm the permitted server event still arrives. In a separate denied-consent test, confirm neither path sends advertising events where permission is required.
4. **Use a release gate.** Don’t scale until receipt, deduplication, value accuracy, and consent behavior are verified. After launch, compare Meta’s received purchases with eligible Shopify orders over the same closed window and time zone. Review delivery errors, match quality, and deduplication diagnostics. Keep that reconciliation separate from **Ads Manager attributed purchases**: a controlled test proves transport, not credit for a real ad interaction.
## 7. Consent and compliance
Configure Shopify Customer Privacy settings or a compatible consent platform before enabling tracking. Honor applicable opt-in, opt-out, and withdrawal signals on **both** paths, including delayed webhook processing. Don’t infer permission from a completed order, and don’t use CAPI to bypass a refusal. Hashing makes identifiers pseudonymous, not anonymous. Document what is shared with Meta, why, and how long it is retained; confirm the settings and disclosures against Meta’s terms and the rules in the markets Cedar & Coil serves.
**Status:** Draft only. No campaign has launched, no performance baseline exists, and no Shopify-to-Meta delivery has been verified.