# Cedar & Coil: Shopify → Meta conversion tracking implementation guide
**Scope:** Draft implementation guidance only. Nothing has been installed, sent, or tested. No campaign has launched and there is no performance baseline. The Arc Clip Lamp’s stated price is $68, but the store currency, Shopify product/variant IDs, and Meta catalog IDs were not supplied. Resolve these from the store before configuring events; do not assume USD.
## 1. Recommended architecture: Pixel + Conversions API
Use the **Meta Pixel in the visitor’s browser** for the shopping funnel and a **server-side Meta Conversions API (CAPI) event for the confirmed purchase**. The Pixel records events while the page is available; CAPI sends an event from the store’s trusted server/order system. Together, they provide browser coverage and a server path that is less exposed to browser blockers and cookie limits. CAPI can also carry permitted, normalized customer matching data more reliably.
Neither path makes consent optional: do not send events for visitors who have declined applicable advertising tracking. CAPI can improve delivery of events the store is permitted to collect; it must not be used to recreate tracking for a denial.
For this Shopify store, start with the official **Facebook & Instagram by Meta** sales channel. It’s the lower-maintenance route and supports browser Pixel tracking plus server-side Purchase through CAPI at the channel’s **Enhanced** or **Maximum** data-sharing setting. Verify the actual event sources and deduplication in Events Manager rather than assuming every funnel event is server-side. Add custom CAPI only if a verified requirement is not met by the native channel.
## 2. Standard events and parameters
Use Meta’s exact standard event names and fire each on the actual event—not on a button click or attempted action.
| Event | Fire when | Core parameters |
|---|---|---|
| `ViewContent` | A product page/product is actually viewed. | `content_ids` (catalog-matching product or variant ID), `content_type` (`product` or `product_group`, matching the catalog), optional `content_name` (Arc Clip Lamp), displayed item `value`, and `currency`. |
| `AddToCart` | Shopify confirms the item was added to cart. | `content_ids`, `content_type`, `contents` (each item’s `id`, `quantity`, and optionally `item_price`), quantity/`num_items`, value of the item(s) added, and `currency`. |
| `InitiateCheckout` | The shopper actually enters checkout. | `content_ids`/`contents` for checkout items, `num_items`, checkout `value`, and `currency`. Use the same documented value basis as the other events. |
| `Purchase` | A completed/confirmed order—not checkout start or a thank-you-page refresh. | Actual order `value`, `currency`, `content_ids` for purchased catalog items, `content_type`, `contents` with item IDs and quantities, `num_items`, and optionally `order_id` as a reporting parameter. Also send `event_id` for deduplication. |
Use the **actual Shopify/catalog ID that matches the ID in Meta’s product catalog**; don’t guess whether that should be a product or variant ID. The supplied product price is $68, but currency and variants are unspecified. Read the displayed/ordered amounts and ISO 4217 currency from Shopify at event time.
Decide and document one value convention—such as merchandise subtotal or total paid including tax/shipping—and apply it consistently to Pixel and CAPI. Keep item-level values consistent with that convention. For `Purchase`, use the actual order amount under that policy, not a hard-coded $68. `order_id` is useful context but is **not** Meta’s deduplication key.
## 3. Exactly how Pixel/CAPI deduplication works
For each real event sent by both sources, Meta deduplicates using the pair **`event_name` + `event_id`**. Both values must match exactly, including capitalization. For example, a browser `Purchase` with `eventID: "shopify_123"` must pair with a server `event_name: "Purchase"` and `event_id: "shopify_123"`. `purchase` is not the same event name as `Purchase`.
Use one stable, unique ID for that occurrence, share it with both senders, and never reuse it for another purchase. Do not generate separate random IDs in the browser and server. A changed format, case, or regenerated ID breaks the match and can count a sale twice. The same rule applies to any other event intentionally sent through both paths.
With Shopify’s native channel, let the channel own its Pixel/CAPI pairing. Don’t add another Purchase sender—such as custom pixel, GTM, theme code, another app, or a DIY webhook—unless you can prove it shares the exact event name and ID and Events Manager shows the pair as deduplicated. If you can’t make the ID available identically to both custom senders, don’t run both for that event.
## 4. Preparing customer information for server-side events
Send only information the store actually has and is permitted to use. For CAPI `user_data`:
- Normalize email by trimming whitespace and lowercasing, then SHA-256 hash it.
- Normalize phone to E.164 using a known country context, then SHA-256 hash it. Don’t infer a country code from the phone number or store location.
- Hash other supported personal identifiers according to Meta’s current specifications; don’t hash values Meta expects raw.
- If collected with permission, pass `_fbp` (`fbp`), `_fbc` (`fbc`), client IP (`client_ip_address`), and browser user agent (`client_user_agent`) in their expected raw formats. Preserve valid click/browser identifiers from the original visit; don’t fabricate them.
- Include at least one eligible matching identifier when sending a CAPI event. Omit fields that are unavailable; never send placeholders, raw email/phone, unrelated sensitive data, or secrets in logs.
Keep the dataset access token server-side in a secret manager or environment variable. Verify Shopify webhook authenticity before trusting an order payload. Restrict access to event logs and redact credentials and personal data.
## 5. Concrete Shopify setup: native channel vs. custom
### Recommended for a small DTC store: native Meta sales channel
1. In Shopify Admin, open **Sales channels / Shopify App Store** and install the official **Facebook & Instagram by Meta** channel.
2. Connect the correct Meta business portfolio and select the website dataset/Pixel and relevant ad account. Confirm IDs and ownership before continuing. Reuse the existing dataset if one already represents the store rather than splitting data across duplicates.
3. In the channel’s data-sharing settings, choose **Enhanced** or **Maximum** only if the associated data use is permitted under the store’s consent and privacy setup. This enables the channel’s server-side Purchase path through CAPI. Keep the Pixel and CAPI connection managed by the channel.
4. Inventory and disable duplicate senders for this dataset: old theme code, GTM tags, Shopify custom pixels, and other Meta tracking apps. Use Shopify’s supported sales-channel/customer-events surfaces, not legacy checkout-script instructions.
5. Verify the four standard events and the Purchase’s browser/server sources in Events Manager Test Events before relying on the setup.
This is the recommended first choice because Shopify maintains the integration and it avoids owning custom API plumbing. It does **not** mean every event is sent server-side: verify which events are browser versus server in Test Events. If you need more control, server-side funnel events beyond Purchase, or the native channel does not meet a specific requirement, consider a custom integration.
### Custom implementation
A custom build needs a Shopify app/web pixel for browser events plus a verified server-side order signal—such as a confirmed-order webhook—that sends CAPI. The team then owns webhook verification, consent gating, ID sharing, value/catalog mapping, hashing, retries, token rotation, monitoring, and API-version maintenance. Don’t layer it on top of the native channel without an explicit sender map and deduplication proof.
Illustrative Node.js sketch for a server-side Purchase request (**not** a drop-in Shopify webhook handler):
```js
import { createHash } from "node:crypto";
const sha256 = (value) =>
createHash("sha256").update(value, "utf8").digest("hex");
// `order` must come from a verified, consent-eligible Shopify order event.
// These normalized fields must be populated from the actual order/catalog.
const eventId = `shopify_${order.id}`; // unique per order; same exact ID must reach Pixel
const userData = {};
if (order.email) {
userData.em = [sha256(order.email.trim().toLowerCase())];
}
if (order.phoneE164) {
userData.ph = [sha256(order.phoneE164)];
}
if (order.fbp) userData.fbp = order.fbp; // raw browser identifier
if (order.fbc) userData.fbc = order.fbc; // raw click identifier
if (order.clientIp) userData.client_ip_address = order.clientIp;
if (order.userAgent) userData.client_user_agent = order.userAgent;
const event = {
event_name: "Purchase",
event_time: Math.floor(new Date(order.completedAt).getTime() / 1000),
event_id: eventId,
action_source: "website",
event_source_url: order.sourceUrl,
user_data: userData,
custom_data: {
value: order.metaValue, // actual amount under the documented value policy
currency: order.currency, // actual ISO 4217 currency; do not default to USD
content_ids: order.catalogIds, // IDs mapped to the Meta catalog
content_type: "product",
contents: order.items.map((item) => ({
id: item.catalogId,
quantity: item.quantity,
item_price: item.unitPrice,
})),
num_items: order.items.reduce((n, item) => n + item.quantity, 0),
order_id: String(order.id),
},
};
const endpoint = new URL(
`https://graph.facebook.com/${process.env.META_GRAPH_API_VERSION}/${process.env.META_DATASET_ID}/events`
);
endpoint.searchParams.set("access_token", process.env.META_CAPI_TOKEN);
const payload = { data: [event] };
if (process.env.META_TEST_EVENT_CODE) {
payload.test_event_code = process.env.META_TEST_EVENT_CODE;
}
const response = await fetch(endpoint, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(payload),
});
const result = await response.json();
if (!response.ok || result.error) {
throw new Error("Meta CAPI request failed");
}
// Inspect and securely log the provider's result; never log the token or raw PII.
```
The corresponding browser event must use the identical event ID, for example:
```js
fbq("track", "Purchase", purchaseParams, { eventID: eventId });
```
The browser must actually have access to that same order-level ID; if not, don’t claim deduplication or run a second Purchase sender. Use the current Graph API version, handle retries and errors, and keep `event_time` within Meta’s accepted window (the implementation reference says no more than seven days old). In production, pass `test_event_code` only for test events. A verified webhook handler must also validate Shopify’s signature and use the platform’s current webhook contract; this sketch omits that security-critical plumbing.
## 6. Validate end to end before scaling spend
1. **Preflight the map:** record Shopify store currency, product/variant IDs, Meta catalog IDs, dataset ID, value convention, consent behavior, and every sender currently installed. Resolve the missing currency and IDs before going live.
2. **Test in Meta Events Manager → the correct dataset → Test Events.** Use the test browser flow for Pixel events and a `test_event_code` for a custom CAPI test. Use Shopify/payment-provider test mode or another store-approved test-order method; don’t create a chargeable order just to test without authorization.
3. **Walk the funnel:** product view → confirmed add-to-cart → checkout start → completed test order. Expected standard events are `ViewContent`, `AddToCart`, `InitiateCheckout`, and one `Purchase`, each with the expected IDs, value, and currency. For a Pixel+CAPI Purchase pair, expect one event marked deduplicated—not two counted purchases.
4. **Check browser and server separately:** Pixel/network tools show the browser send; Test Events shows whether Meta received it. Confirm the server event is accepted and carries `action_source`, a recent `event_time`, `event_id`, and eligible `user_data`. A tag firing alone is not proof of receipt.
5. **Check consent:** with valid advertising consent, permitted events should flow; for a denial or applicable opt-out, neither Pixel nor CAPI should bypass that choice. Verify the actual storefront privacy configuration rather than testing only an already-consented browser.
6. **Check diagnostics and counts:** look for duplicate Pixel installs, missing parameters, rejected server events, and value/catalog mismatches. Reconcile the test Purchase to the Shopify order record. Allow the platform’s reporting/diagnostics to update before judging production counts; no campaign results can be assessed until there is real traffic and a launched campaign.
Don’t scale spend until the four events are received as expected, the Purchase is deduplicated once, values/currency/catalog IDs reconcile, and consent behavior is verified. This guide makes no promise about a particular attribution-recovery percentage.
## 7. Consent and compliance
Follow applicable privacy and advertising rules, the store’s privacy notice, and Shopify’s customer privacy/consent settings. Gate both browser and server sends on required advertising consent and honor opt-outs/GPC where applicable. CAPI is a delivery method, not a legal basis or consent workaround; visitors who decline remain untracked. Minimize the personal data sent, hash identifiers as required, protect access tokens, set appropriate retention/access controls, and get qualified privacy advice for the store’s jurisdictions. Choose Enhanced/Maximum data sharing only after the store confirms its permitted data use.
Saved copy: [implementation-guide.md](resources/evals/20261118-192546-15b4c0b7/shopify-meta-capi/implementation-guide.md).