← Run 20260826-052545-86a467c8
Shopify to Meta ads conversion tracking implementation
task shopify-meta-capiAug 26, 2026

Answers & verdicts

Claude Sonnet 5 default

Task failed
Task the exact prompt the model was given — assignment and source material
Cedar & Coil sells the Arc Clip Lamp on Shopify and is preparing Meta ads. Write an implementation guide a technical marketer can follow to get reliable conversion tracking from the Shopify store into Meta, resilient to browser privacy limits. Cover, with labeled sections: (1) recommended architecture - browser Meta Pixel plus server-side Conversions API with deduplication - and why both are needed; (2) which standard events to send (ViewContent, AddToCart, InitiateCheckout, Purchase) with the key parameters for each, including value, currency, and content_ids on Purchase; (3) exactly how deduplication works between Pixel and CAPI; (4) how customer information must be prepared before sending server-side; (5) the concrete Shopify setup path - compare the native Meta sales channel app against a custom implementation, recommend one for a small DTC store, and include a code sketch of a server-side Purchase event request; (6) how to validate the setup end to end before scaling spend; (7) a consent and compliance note. Do not promise specific attribution recovery percentages. --- ## Supplied source: product-marketing.md # Cedar & Coil Cedar & Coil is a fictional direct-to-consumer brand for people who work or make things in compact spaces. Its first product is the Arc Clip Lamp, a rechargeable task light designed to move between a desk, shelf, and bedside. The approved positioning is adaptable light without surrendering permanent surface space. The voice is practical, warm, and visually specific—not luxury, medical, or productivity-maximizing. All campaign work must remain draft-only. Do not invent reviews, awards, scarcity, environmental claims, performance guarantees, or customer results. --- ## Supplied source: facts.md # Authoritative synthetic facts - Product: Arc Clip Lamp. - Price: $68. - Included: lamp, padded clamp, USB-C charging cable, and storage sleeve. - Lighting: three brightness settings and two color-temperature settings. - Battery statement allowed: up to eight hours on the lowest brightness. - Clamp opening: surfaces up to 2.25 inches thick. - Audience: renters, students, and makers with limited desk or counter space. - Approved CTA: Explore the Arc Clip Lamp. - No campaign has launched and no performance data exists.
Answer the model's full response$0.17 · 111.9s · 8.3k tok
# Cedar & Coil — Meta Conversion Tracking Implementation Guide **Scope:** This guide covers the Arc Clip Lamp Shopify store only. No campaign has launched and no performance data exists yet — treat all match-rate, dedup, and event-quality figures below as *mechanisms to configure*, not results to expect. Nothing in this guide should be read as a promise of a specific attribution-recovery percentage; actual match rates depend on traffic mix, consent rates, and browser behavior that can't be predicted in advance. --- ## 1. Recommended Architecture: Browser Pixel + Server-Side CAPI (with Deduplication) The recommended setup is **both** the Meta Pixel (client-side, fires from the customer's browser) and the Meta Conversions API — CAPI (server-side, fires from Shopify's servers or your own backend), sending the *same* events with a shared identifier so Meta can deduplicate them. Why both, rather than just picking one: - **The Pixel alone is fragile.** It depends on JavaScript executing in the customer's browser, so it is degraded or blocked entirely by ad blockers, Safari's Intelligent Tracking Prevention, Firefox Enhanced Tracking Protection, and by users declining marketing cookies. A page abandoned before it fully loads also drops the event. - **CAPI alone loses some signal quality.** Server-side events don't automatically carry browser-native identifiers like the `fbp`/`fbc` cookies that link a click to a session, and a server-only setup gives you no independent way to sanity-check what the browser actually saw. - **Together, they're complementary.** The Pixel supplies rich browser context (click IDs, cookies, real-time page behavior) when it's allowed to run; CAPI supplies a durable, server-owned copy of the same event that fires regardless of browser restrictions. Meta's matching and deduplication logic is designed specifically for this pattern — it treats the pair as one event, not two, as long as they're linked correctly (see Section 3). The architecture in one line: **Shopify storefront → Meta Pixel (browser) → Meta**, and in parallel, **Shopify order/checkout event → your server or Shopify's native connector → Meta CAPI → Meta**, with both legs tagged with the same `event_id`. --- ## 2. Standard Events and Key Parameters Send Meta's standard events (not custom events) so they map cleanly to ads-manager reporting and optimization. For each, populate `currency` and `value` even when the event isn't a purchase — Meta's optimization and ROAS reporting depend on consistent value data across the funnel. **ViewContent** (product page view — e.g., the Arc Clip Lamp PDP) - `content_ids`: `["arc-clip-lamp"]` (or the Shopify variant/SKU ID if you track by variant) - `content_type`: `"product"` - `content_name`: `"Arc Clip Lamp"` - `currency`: `"USD"` - `value`: `68.00` **AddToCart** - `content_ids`, `content_type`, `content_name` — same as above - `contents`: array with `id` and `quantity` (supports multi-line carts) - `currency`, `value`: reflect the line-item value being added, not necessarily the full cart **InitiateCheckout** - `content_ids`, `content_type` - `num_items`: count of units in the checkout - `currency`, `value`: full cart value at checkout start **Purchase** (the event Meta optimizes delivery against, so it must be complete and accurate) - `content_ids`: array of purchased product/variant IDs — required so Meta can attribute revenue to the specific SKU (important once Cedar & Coil adds more products beyond the Arc Clip Lamp) - `content_type`: `"product"` - `contents`: line items with `id`, `quantity`, `item_price` - `currency`: `"USD"` - `value`: the final order total actually charged (not list price) — this is the number Meta reports as revenue and optimizes toward, so it must reconcile with Shopify's order total including any discounts, but conventions vary on shipping/tax; pick one rule and apply it consistently across Pixel and CAPI - `order_id` (Shopify order ID, mapped to Meta's `event_id` for dedup — see Section 3) --- ## 3. How Deduplication Works Between Pixel and CAPI When both channels are live, Meta will receive two transmissions of the same real-world event — one from the browser, one from the server — and needs a deterministic way to know they're the same event rather than two separate conversions. The mechanism is the shared **`event_id`**. To ensure proper deduplication, both the Meta Pixel (client-side) and the Conversions API (server-side) must send the same event_id for each conversion event. Concretely, Meta checks three things together: 1. **Matching `event_name`** — the event name must be the same (e.g., Purchase, AddToCart) on both the browser and server payload. 2. **Matching `event_id`** — the two events must carry an identical, unique ID string. For Purchase, the natural choice is the Shopify order ID (or a UUID generated at checkout and passed to both the Pixel and the server call). 3. **Close `event_time`** — the two timestamps should be close together, ideally within seconds, since Meta uses this as an additional sanity check. Practically, this means your implementation must generate the `event_id` once, at the moment the conversion happens (e.g., in the checkout confirmation page's JavaScript), and pass that exact same string into both the client-side `fbq('track', 'Purchase', {...}, {eventID: '...'})` call and the server-side CAPI payload for that same order. If the IDs don't match exactly, Meta will count both events, inflating your purchase and revenue numbers. `action_source` should be set to `"website"` on both legs (not `"system_generated"` or `"other"`), since both events originate from the same on-site conversion. --- ## 4. Preparing Customer Information for Server-Side Sending CAPI payloads include a `user_data` object used purely for matching the event to a Meta user — it is not used to build audiences. Meta is strict about the format of this data: - Our systems are designed to not accept customer information that is unhashed Contact Information — email, phone, and name fields must be hashed before they leave your server (or before Shopify's connector sends them). If you are using the Meta Business SDK, the hashing is done automatically; if you're building a custom call, you must hash manually. - **Normalize before hashing**, because hashing is case- and whitespace-sensitive: - Email: lowercase, trim whitespace → SHA-256 → `em` - Phone: strip all non-digits, include country code, no leading `+` or `00` → SHA-256 → `ph` - First/last name: lowercase, trim, strip punctuation → SHA-256 → `fn` / `ln` - **Send everything you legitimately have, not just email.** Include as many of the supported identifiers as are available for that order: hashed email, hashed phone, hashed name, `external_id` (Shopify customer ID, hashed), plus the *unhashed* technical fields `client_ip_address`, `client_user_agent`, and the `fbp`/`fbc` cookie values captured from the browser at the time of the session. These cookie values are what let Meta connect the server-side event back to the original ad click. - **Never fabricate or backfill identifiers** you don't actually have (e.g., don't guess a phone number format or reuse one customer's ID for another). Bad matches degrade signal quality rather than improving it. --- ## 5. Shopify Setup Path ### Option A — Native Meta & Instagram Sales Channel App Shopify ships a first-party "Facebook & Instagram" sales channel that includes built-in CAPI support. In Shopify admin, go to Sales Channels > Facebook & Instagram, link your Meta account, and enable the Conversion API under Data Sharing Settings by selecting Maximum. This automatically fires ViewContent, AddToCart, InitiateCheckout, and Purchase from both Shopify's checkout servers (CAPI) and the storefront Pixel, with Shopify handling event_id generation and dedup for you. ### Option B — Custom Implementation A custom build typically listens to Shopify webhooks (`orders/create`, `carts/update`, or theme-level events) and posts directly to the Meta Graph API `/events` endpoint from your own server (Node/Python function, middleware, or a tag-management server container). This gives full control over parameter mapping, value logic (e.g., excluding shipping from `value`), and multi-destination routing, at the cost of build and maintenance effort. ### Recommendation for a Small DTC Store **Use the native Meta sales channel app.** For a single-SKU store like Cedar & Coil, the engineering cost of a custom pipeline isn't justified: the native app covers the four standard events, handles hashing and dedup automatically, and is maintained by Shopify/Meta as their APIs change. Revisit a custom build only if the store later needs event logic the native app doesn't support (e.g., custom value rules, multi-pixel routing, or non-Shopify data sources feeding the same pixel). ### Code Sketch — Custom Server-Side Purchase Event (for reference / Option B) ```python import hashlib import time import requests def sha256_normalize(value: str) -> str: return hashlib.sha256(value.strip().lower().encode("utf-8")).hexdigest() def send_purchase_event(order, fbp, fbc, client_ip, user_agent, access_token, pixel_id): event_id = str(order["id"]) # same ID must be used in the browser-side fbq() call payload = { "data": [{ "event_name": "Purchase", "event_time": int(time.time()), "event_id": event_id, "action_source": "website", "event_source_url": order["checkout_url"], "user_data": { "em": [sha256_normalize(order["email"])], "ph": [sha256_normalize(order["phone"])] if order.get("phone") else None, "external_id": [sha256_normalize(str(order["customer_id"]))], "client_ip_address": client_ip, "client_user_agent": user_agent, "fbp": fbp, "fbc": fbc, }, "custom_data": { "currency": "USD", "value": order["total_price"], "content_type": "product", "content_ids": [li["variant_id"] for li in order["line_items"]], "contents": [ {"id": li["variant_id"], "quantity": li["quantity"], "item_price": li["price"]} for li in order["line_items"] ], "order_id": str(order["id"]), }, }] } resp = requests.post( f"https://graph.facebook.com/v19.0/{pixel_id}/events", params={"access_token": access_token}, json=payload, ) return resp.json() ``` The matching browser-side call would be `fbq('track', 'Purchase', {value: ..., currency: 'USD', content_ids: [...]}, {eventID: String(order.id)})` — note the identical `event_id`. --- ## 6. Validating End-to-End Before Scaling Spend Do not turn up ad budget until all of the following check out: 1. **Meta Events Manager → Test Events tool.** Place a real test order and confirm both a browser and a server event appear for each of ViewContent, AddToCart, InitiateCheckout, and Purchase, with a visible "deduplicated" indicator (not two separate rows) once both fire. 2. **Meta Pixel Helper (browser extension).** Confirm the Pixel fires on the PDP, cart, checkout, and thank-you pages with the parameters described in Section 2 present and correctly typed (numbers for `value`, not strings; arrays for `content_ids`). 3. **Diagnostics tab in Events Manager.** Check for parameter warnings (missing `currency`, malformed hashes, missing `event_id` on one leg) and resolve all of them. 4. **Event Match Quality score.** Confirm it's populated and review which identifiers are contributing — this tells you if `user_data` is actually reaching Meta, without needing to predict what score you should expect. 5. **Reconcile counts against Shopify.** Over a short test window, compare the number of Purchase events and total value reported in Events Manager to actual Shopify order count and revenue for the same period — they should be closely aligned, not doubled or halved. 6. **Confirm dedup under real conditions**, including at least one order placed with an ad blocker or in a private browsing window, to verify the server-side leg still delivers the event even when the Pixel is blocked. Only after these checks are clean should ad spend be scaled up. --- ## 7. Consent and Compliance Note - Events should only be sent — from either the Pixel or CAPI — after the customer has given the applicable cookie/tracking consent required in their region (e.g., under GDPR for EU/UK visitors). Gate both the client-side Pixel initialization and the server-side event dispatch behind the same consent state so they don't diverge. - Because CAPI moves data server-to-server, it is easy to mistakenly assume it falls outside consent requirements — it does not. If a visitor has not consented, do not send their event via CAPI as a workaround. - Only send genuine customer-provided data (Section 4); do not infer or reconstruct identifiers to improve matching. - Review Meta's current Business Tools Terms and Shopify's data-processing terms for the store's applicable jurisdictions before launch, and keep the consent banner, Pixel firing logic, and CAPI firing logic in sync as either platform's requirements change.
Score the judge's verdict, criterion by criterion10/11 criteria passed · failed: event_time_stable
RequirementVerdictEvidence
architecture
The guide recommends browser Pixel plus server-side Conversions API with deduplication and explains why both are needed under browser privacy limits.
✓Section 1 explicitly recommends 'both the Meta Pixel... and the Meta Conversions API' and explains why each alone is insufficient due to browser privacy limits (ITP, ad blockers, cookie consent).
events_mapped
All four standard events (ViewContent, AddToCart, InitiateCheckout, Purchase) are covered with key parameters, including value, currency, and content_ids on Purchase.
✓Section 2 lists ViewContent, AddToCart, InitiateCheckout, and Purchase with parameters including currency, value, and content_ids for Purchase.
code_sketch
A concrete server-side Purchase event code sketch or request example is included showing event_name, event_time, event_id, action_source, and a user_data block.
✓The Python code sketch in Section 5 includes event_name, event_time, event_id, action_source, and a full user_data block.
validation
End-to-end validation is described using Meta's Events Manager test events tool and an explicit check that duplicate browser/server events are being deduplicated.
✓Section 6 instructs using 'Meta Events Manager → Test Events tool' and explicitly checking for a 'visible deduplicated indicator (not two separate rows)'.
sources_defined
For each event it is clear where it fires (browser vs server) and what the source of truth is (e.g. Purchase from the Shopify order webhook/server, not only the thank-you page).
✓The guide states each event fires from both browser (Pixel) and server (Shopify order/checkout webhook or native connector), with Purchase sourced from the order object/webhook rather than only the thank-you page.
limits_stated
Limitations are stated honestly: no promised attribution-recovery percentages, and consent/regional rules are noted as constraints on what may be sent.
✓The scope note explicitly disclaims 'a promise of a specific attribution-recovery percentage' and Section 7 treats consent/regional rules as hard constraints on what may be sent.
dedup_correct
Deduplication is technically correct: the same event_id and event_name sent on both the Pixel and CAPI event so Meta drops the duplicate; not a vague mention.
✓Section 3 states 'both the Meta Pixel... and the Conversions API... must send the same event_id for each conversion event' and that mismatched IDs cause double counting, correctly describing Meta's dedup mechanism.
event_id_retry_stability
The event_id is generated or derived once per commerce event, shared by browser and server, and reused unchanged on webhook retries or order updates; a new random suffix per send or retry fails.
✓The event_id is derived deterministically from the Shopify order ID ('event_id = str(order["id"])'), ensuring it stays constant across retries rather than using a random suffix per send.
event_time_stable
The server Purchase event uses the purchase/order occurrence timestamp in Unix seconds and preserves it across retries; using the current send or retry time fails.
✗The code sketch sets 'event_time': int(time.time()), which is the current send time rather than the order's occurrence timestamp, violating the stability requirement.
pii_hashing
Customer data handling is correct: personally identifiable fields (e.g. email) are normalized (trimmed, lowercased) and SHA-256 hashed before sending in user_data.
✓Section 4 and the code's sha256_normalize function explicitly lowercase/trim and SHA-256 hash email (and phone) before inclusion in user_data.
actionable_path
The recommended Shopify path is decisive and executable for a small DTC store (a clear recommendation with concrete setup steps, not an undifferentiated list of options).
✓The guide gives a decisive recommendation ('Use the native Meta sales channel app') with concrete steps (Sales Channels > Facebook & Instagram, enable Data Sharing at Maximum) for a small DTC store.

GPT-5.6 Terra medium effort

Task passed
Task the exact prompt the model was given — assignment and source material
Cedar & Coil sells the Arc Clip Lamp on Shopify and is preparing Meta ads. Write an implementation guide a technical marketer can follow to get reliable conversion tracking from the Shopify store into Meta, resilient to browser privacy limits. Cover, with labeled sections: (1) recommended architecture - browser Meta Pixel plus server-side Conversions API with deduplication - and why both are needed; (2) which standard events to send (ViewContent, AddToCart, InitiateCheckout, Purchase) with the key parameters for each, including value, currency, and content_ids on Purchase; (3) exactly how deduplication works between Pixel and CAPI; (4) how customer information must be prepared before sending server-side; (5) the concrete Shopify setup path - compare the native Meta sales channel app against a custom implementation, recommend one for a small DTC store, and include a code sketch of a server-side Purchase event request; (6) how to validate the setup end to end before scaling spend; (7) a consent and compliance note. Do not promise specific attribution recovery percentages. --- ## Supplied source: product-marketing.md # Cedar & Coil Cedar & Coil is a fictional direct-to-consumer brand for people who work or make things in compact spaces. Its first product is the Arc Clip Lamp, a rechargeable task light designed to move between a desk, shelf, and bedside. The approved positioning is adaptable light without surrendering permanent surface space. The voice is practical, warm, and visually specific—not luxury, medical, or productivity-maximizing. All campaign work must remain draft-only. Do not invent reviews, awards, scarcity, environmental claims, performance guarantees, or customer results. --- ## Supplied source: facts.md # Authoritative synthetic facts - Product: Arc Clip Lamp. - Price: $68. - Included: lamp, padded clamp, USB-C charging cable, and storage sleeve. - Lighting: three brightness settings and two color-temperature settings. - Battery statement allowed: up to eight hours on the lowest brightness. - Clamp opening: surfaces up to 2.25 inches thick. - Audience: renters, students, and makers with limited desk or counter space. - Approved CTA: Explore the Arc Clip Lamp. - No campaign has launched and no performance data exists.
Answer the model's full response$0.20 · 90.3s · 7.9k tok
# Draft: Meta Conversion Tracking Implementation Guide for Cedar & Coil **Goal:** measure the Arc Clip Lamp funnel on Shopify reliably enough to optimize Meta ads while remaining resilient to browser-side loss. Use a single Meta dataset/pixel and a clean, documented event taxonomy. Do **not** install multiple Meta pixels or let multiple tools send the same event unless you have intentionally designed deduplication. ## 1. Recommended architecture: Meta Pixel + Conversions API ### Recommended design Use both: 1. **Browser Meta Pixel** Sends browser-side events from the Shopify storefront and checkout: - `ViewContent` - `AddToCart` - `InitiateCheckout` - `Purchase` 2. **Server-side Meta Conversions API (CAPI)** Sends a server-confirmed version of the same important conversion actions—at minimum `Purchase`—to the **same Meta pixel/dataset**. 3. **Deduplication key shared by both copies** When the same customer action is sent by both browser and server, give both events the same: - `event_name` - `event_id` ### Why use both The browser Pixel provides the immediate on-site behavioral trail: product views, cart adds, checkout starts, source URL, and browser identifiers such as `_fbp` and `_fbc` when available. However, browser events can be limited by ad blockers, browser privacy controls, network failures, or a shopper leaving before the confirmation page finishes loading. CAPI sends events from Cedar & Coil’s server environment, so it is not dependent on a browser successfully delivering the event. It is especially valuable for a confirmed `Purchase`, because the server can use the final Shopify order record rather than a page-load signal. It does **not** replace the Pixel: server events alone lose useful browser/session context and funnel behavior. The intended design is redundant event delivery with correct deduplication, not two separate conversion counts. ([help.shopify.com](https://help.shopify.com/en/manual/promoting-marketing/analyze-marketing/meta-data-sharing)) ### Practical baseline for this store For a small Shopify DTC store, use: | Funnel stage | Browser Pixel | CAPI | |---|---:|---:| | `ViewContent` | Yes | Optional initially | | `AddToCart` | Yes | Optional initially | | `InitiateCheckout` | Yes | Optional initially | | `Purchase` | Yes | Yes, server-confirmed | This preserves the full funnel while making the business-critical purchase event more resilient. --- ## 2. Standard events and required payloads Use Meta’s **standard event names** exactly. For every event, keep product identifiers consistent with the IDs in the Meta catalog. If the catalog uses Shopify variant IDs, send Shopify variant IDs everywhere; do not send a product handle on one event and SKU on another. Shopify’s Meta integration automatically supports the four key browser events: product view, add to cart, checkout initiation, and purchase. ([help.shopify.com](https://help.shopify.com/en/manual/promoting-marketing/analyze-marketing/meta-data-sharing)) ### Event schema | Meta event | Fire when | Key parameters | |---|---|---| | `ViewContent` | The Arc Clip Lamp product page is viewed | `content_ids`, `content_type`, `content_name`, `value`, `currency` | | `AddToCart` | A shopper successfully adds the item to cart—not merely clicks a button | `content_ids`, `contents`, `content_type`, `value`, `currency` | | `InitiateCheckout` | The shopper enters or starts checkout | `content_ids`, `contents`, `content_type`, `value`, `currency`, `num_items` | | `Purchase` | Shopify confirms checkout/order completion | `content_ids`, `contents`, `content_type`, `value`, `currency`, `order_id` | For CAPI events, also send the general event fields: - `event_name` - `event_time` — Unix timestamp in seconds for when the action occurred - `event_id` — required for paired Pixel/CAPI deduplication - `action_source: "website"` - `event_source_url` where available - `user_data` - `custom_data` containing the commerce payload Meta documents `value` as numeric, `currency` as an ISO 4217 three-letter code such as `USD`, and supports `content_ids`, `contents`, `content_type`, `order_id`, and `num_items`. ([github.com](https://github.com/facebookincubator/Facebook-Server-Side-API-Swagger/blob/main/server-side-api.yaml)) ### Recommended event payloads #### `ViewContent` ```js fbq("track", "ViewContent", { content_ids: ["SHOPIFY_VARIANT_ID"], content_type: "product", content_name: "Arc Clip Lamp", value: 68.00, currency: "USD" }, { eventID }); ``` Use the active selected variant’s identifier and price. If Cedar & Coil adds variants later, send the exact selected variant ID—not a generic product identifier—unless the catalog is intentionally configured around product-group IDs. #### `AddToCart` ```js fbq("track", "AddToCart", { content_ids: ["SHOPIFY_VARIANT_ID"], content_type: "product", content_name: "Arc Clip Lamp", contents: [ { id: "SHOPIFY_VARIANT_ID", quantity: 1, item_price: 68.00 } ], value: 68.00, currency: "USD" }, { eventID }); ``` Fire only after Shopify has accepted the cart addition. This matters for quick-add buttons, out-of-stock states, and cart drawers that can fail or be interrupted. #### `InitiateCheckout` ```js fbq("track", "InitiateCheckout", { content_ids: ["SHOPIFY_VARIANT_ID"], content_type: "product", contents: [ { id: "SHOPIFY_VARIANT_ID", quantity: 1, item_price: 68.00 } ], value: 68.00, currency: "USD", num_items: 1 }, { eventID }); ``` Use the cart total at the moment checkout begins. `num_items` is specifically supported for `InitiateCheckout`. ([github.com](https://github.com/facebookincubator/Facebook-Server-Side-API-Swagger/blob/main/server-side-api.yaml)) #### `Purchase` ```js fbq("track", "Purchase", { content_ids: ["SHOPIFY_VARIANT_ID"], content_type: "product", contents: [ { id: "SHOPIFY_VARIANT_ID", quantity: 1, item_price: 68.00 } ], value: 68.00, currency: "USD", order_id: "SHOPIFY_ORDER_ID" }, { eventID }); ``` For the server copy of `Purchase`, use Shopify’s final order data: - final paid/order total - final order currency - actual line items and quantities - Shopify order ID - final discounts, shipping, taxes, and duties according to the store’s selected order-total convention Shopify notes that its Meta order-value events use the order total, including item prices, duties, taxes, and discounts. Whichever convention Cedar & Coil uses, the Pixel and CAPI copies must use the **same** value and currency for the same order. ([help.shopify.com](https://help.shopify.com/en/manual/promoting-marketing/analyze-marketing/meta-data-sharing)) --- ## 3. Exactly how Pixel/CAPI deduplication works ### The matching rule For a browser event and a server event to be treated as the same conversion, send: - the same Meta pixel/dataset - the same `event_name` - the same `event_id` Example for order `gid://shopify/Order/1234567890`: ```text event_name: Purchase event_id: purchase:gid://shopify/Order/1234567890 ``` The browser Pixel `Purchase` and the CAPI `Purchase` must both use that exact string. Meta’s documented deduplication uses matching event name and event ID. Matching events received within 48 hours are considered duplicates, and the later copy is discarded for counting. ([github.com](https://github.com/facebookincubator/Facebook-Server-Side-API-Swagger/blob/main/server-side-api.yaml)) ### What **not** to do - **Do not** generate one random ID in the browser and a different random ID on the server. - **Do not** use the same `event_id` for different customer actions. - **Do not** send `Purchase` through the Shopify Meta channel, GTM, a theme snippet, and a custom CAPI endpoint simultaneously. - **Do not** use the order ID as the ID for `AddToCart` or `InitiateCheckout`; those actions occur before an order exists. - **Do not** change an event ID during retries. Retries must reuse the original ID. ### Recommended event-ID patterns | Event | Event ID pattern | |---|---| | `ViewContent` | `vc:<pageview-or-uuid>` | | `AddToCart` | `atc:<cart-line-id-or-uuid>` | | `InitiateCheckout` | `ic:<checkout-id>` | | `Purchase` | `purchase:<shopify-order-global-id>` | For paired CAPI and Pixel events, the ID needs to be generated once and made available to both delivery paths. For `Purchase`, use a deterministic ID derived from the Shopify order ID. Shopify Web Pixels exposes the order ID on `checkout_completed`, making this feasible in a custom implementation. ([shopify.dev](https://shopify.dev/docs/api/web-pixels-api/standard-events/checkout_started?utm_source=openai)) ### Separate Meta deduplication from Cedar & Coil’s own idempotency Implement an internal event ledger as well: ```text unique key: meta_pixel_id + event_name + event_id status: queued | sent | accepted | retrying | failed ``` That ledger prevents Cedar & Coil’s job runner or webhook processor from repeatedly sending the same event. Meta-side deduplication is a safety net, not a reason to allow uncontrolled duplicate processing. --- ## 4. Preparing customer information for server-side events CAPI uses `user_data` to help Meta match a server event to the appropriate person or browser. Send only information Cedar & Coil legitimately collected and is permitted to use for this purpose. ### Send these where available **Hashed identifiers:** - `em` — email - `ph` — phone - `fn` — first name - `ln` — last name - `ct` — city - `st` — state/region - `zp` — ZIP/postcode - `country` — two-letter country code - `external_id` — stable Cedar & Coil customer identifier, if used consistently **Raw browser/request identifiers:** - `fbp` — Meta browser ID from `_fbp` - `fbc` — Meta click ID from `_fbc`, or derived from `fbclid` where permitted - `client_ip_address` - `client_user_agent` Meta’s API schema specifies SHA-256 hashing for contact and address identifiers such as email, phone, first/last name, city, state, ZIP, and country. It specifies `fbc`, `fbp`, IP address, and user agent as separate fields; do not SHA-256 hash those browser/request values. ([github.com](https://github.com/facebookincubator/Facebook-Server-Side-API-Swagger/blob/main/server-side-api.yaml)) ### Normalization rules before SHA-256 Perform normalization **before** hashing: | Field | Normalize before hashing | |---|---| | Email | Trim whitespace; lowercase | | Phone | Digits only; include country code, e.g. `14155551212` | | First/last name | Trim; lowercase | | City | Lowercase; remove spaces and punctuation | | State | Lowercase state/region code where applicable | | Country | Lowercase ISO two-letter code, e.g. `us` | | ZIP | Use the applicable standard postal-code format | | External ID | Use a stable identifier consistently; hash if that is Cedar & Coil’s chosen convention | Example: ```js import crypto from "node:crypto"; const sha256 = (value) => crypto.createHash("sha256").update(value, "utf8").digest("hex"); const normalizedEmail = order.email.trim().toLowerCase(); const normalizedPhone = order.phone.replace(/\D/g, ""); const userData = { em: [sha256(normalizedEmail)], ph: normalizedPhone ? [sha256(normalizedPhone)] : undefined, fbp: browserContext.fbp, // not hashed fbc: browserContext.fbc, // not hashed client_ip_address: browserContext.ip, // not hashed client_user_agent: browserContext.userAgent // not hashed }; ``` ### Data-handling rules - Hash identifiers on Cedar & Coil’s server; do not expose the CAPI access token in theme code, a custom pixel, or a browser request. - Retrieve final commerce values from Shopify’s server-side order data. Do not trust a browser-posted price, quantity, email, or order total as authoritative. - Keep the `fbp`, `fbc`, IP, user agent, event source URL, and consent state captured at the time of the shopper session where possible. - Avoid sending empty strings, placeholders, or fabricated data. - Restrict access to raw customer data and logs; redact personal data from debug logging. --- ## 5. Shopify setup path: native Meta channel vs. custom implementation ## Option A — Shopify’s native Facebook & Instagram by Meta sales channel ### What it provides Shopify’s native channel installs and manages the Meta Pixel and provides data-sharing levels: - **Standard:** browser Pixel - **Enhanced:** browser Pixel plus CAPI purchase event - **Maximum:** browser Pixel plus CAPI purchase event and Meta’s latest advertising technology Shopify documents that the browser Pixel automatically tracks `ViewContent`, `AddToCart`, `InitiateCheckout`, and `Purchase`; its Enhanced and Maximum settings add server-to-server CAPI for `Purchase`. ([help.shopify.com](https://help.shopify.com/en/manual/promoting-marketing/analyze-marketing/meta-data-sharing)) ### Setup steps 1. In Shopify Admin, install or open **Facebook & Instagram by Meta** under **Sales channels**. 2. Connect the correct Meta business portfolio, ad account, catalog, and **one** Meta pixel/dataset. 3. Go to: - **Sales channels → Facebook & Instagram → Settings → Data sharing settings** 4. Enable customer data sharing. 5. Choose **Enhanced** or **Maximum** only after Cedar & Coil’s consent configuration and privacy notice are ready. 6. Connect the selected Meta pixel. 7. Publish the Arc Clip Lamp to the Facebook & Instagram sales channel so its Shopify product/variant identifiers align with the Meta catalog. 8. Remove any duplicate Meta Pixel code from: - `theme.liquid` - Shopify Online Store Preferences - GTM containers - old tracking apps - agency-installed snippets Shopify specifically warns that retaining manually installed Meta Pixel code after connecting the sales channel can create duplicate or incorrect reporting. ([help.shopify.com](https://help.shopify.com/en/manual/promoting-marketing/analyze-marketing/meta-pixel)) ### Advantages - Fastest, lowest-maintenance path. - Shopify manages checkout compatibility. - Native catalog sync helps keep event product IDs aligned to catalog products. - Provides Pixel funnel events and CAPI purchase coverage without Cedar & Coil handling a Meta access token or building a CAPI service. ### Limitations - Shopify’s documented native CAPI coverage is specifically the `Purchase` event; it is not the same as a fully custom server-side implementation of every funnel stage. - Cedar & Coil has less control over payload shaping, enrichment, logging, retry behavior, and event-routing rules. - It is not the right option if a technical team needs a first-party event warehouse, custom order-status rules, subscriptions, offline conversions, or CAPI delivery for all funnel events. ## Option B — Custom Pixel + custom CAPI service ### What it entails A custom implementation generally includes: 1. A Shopify **web pixel** subscribing to standard customer events: - `product_viewed` - `product_added_to_cart` - `checkout_started` - `checkout_completed` 2. Browser-side Meta Pixel calls using Shopify event payloads rather than DOM scraping. 3. A Cedar & Coil server endpoint or queue for CAPI. 4. A verified Shopify order webhook or Admin API lookup to enrich and validate the completed order before sending the server `Purchase`. 5. An event-ID strategy that joins browser and server copies. Shopify Web Pixels provide access to storefront, checkout, and post-purchase customer events, and Shopify recommends Web Pixels rather than legacy DOM scraping for analytics implementations. ([shopify.dev](https://shopify.dev/docs/apps/build/marketing/pixels)) ### Advantages - Full control over event payloads, event IDs, customer-data preparation, retries, and observability. - Can send CAPI for all four events if justified. - Can create a first-party tracking ledger and reconcile CAPI requests against Shopify orders. - Better fit for a larger stack or nonstandard checkout/order logic. ### Risks and costs - More engineering and QA. - Requires secure storage and rotation of Meta access tokens. - Requires webhook verification, retry handling, consent gating, and a customer-data policy. - Requires careful checkout-extensibility compatibility and ongoing maintenance. - A custom pixel runs in Shopify’s sandbox; code should use Shopify’s provided customer event payloads rather than assuming ordinary top-frame browser/DOM access. ([shopify.dev](https://shopify.dev/docs/apps/build/marketing/pixels)) ## Recommendation for Cedar & Coil **Start with Shopify’s native Facebook & Instagram by Meta sales channel using Enhanced or Maximum data sharing, subject to valid consent and privacy configuration.** That is the recommended small-store baseline because it produces the required browser funnel events and adds server-side purchase delivery without custom infrastructure. Do **not** layer a custom `Purchase` CAPI service on top of it for the same pixel unless the exact deduplication design has been tested. Move to a custom implementation only if Cedar & Coil has a clear requirement that the native channel cannot meet—for example, server-side delivery of non-purchase funnel events, custom event transformations, a warehouse-backed measurement system, or special order flows. ### Code sketch: custom server-side `Purchase` request This is illustrative for a **fully custom** build, not something to add alongside the native Shopify Meta channel. ```js import crypto from "node:crypto"; const META_PIXEL_ID = process.env.META_PIXEL_ID; const META_CAPI_TOKEN = process.env.META_CAPI_TOKEN; const META_API_VERSION = process.env.META_API_VERSION; // keep current in deployment config const sha256 = (value) => crypto.createHash("sha256").update(value, "utf8").digest("hex"); async function sendPurchaseToMeta({ shopifyOrder, browserContext, testEventCode }) { // Use the same deterministic ID used by the browser Pixel Purchase call. // Example browser event ID: // purchase:gid://shopify/Order/1234567890 const eventId = `purchase:${shopifyOrder.admin_graphql_api_id}`; const lineItems = shopifyOrder.line_items.map((line) => ({ id: String(line.variant_id), // Must match the Meta catalog ID strategy quantity: line.quantity, item_price: Number(line.price) })); const userData = {}; if (shopifyOrder.email) { userData.em = [sha256(shopifyOrder.email.trim().toLowerCase())]; } if (shopifyOrder.phone) { const digits = shopifyOrder.phone.replace(/\D/g, ""); if (digits) userData.ph = [sha256(digits)]; } // Capture these during the browser session, subject to consent. if (browserContext?.fbp) userData.fbp = browserContext.fbp; if (browserContext?.fbc) userData.fbc = browserContext.fbc; if (browserContext?.ip) userData.client_ip_address = browserContext.ip; if (browserContext?.userAgent) { userData.client_user_agent = browserContext.userAgent; } const body = { data: [{ event_name: "Purchase", event_time: Math.floor( new Date(shopifyOrder.processed_at).getTime() / 1000 ), event_id: eventId, action_source: "website", event_source_url: browserContext?.eventSourceUrl, user_data: userData, custom_data: { currency: shopifyOrder.currency, value: Number(shopifyOrder.total_price), content_type: "product", content_ids: lineItems.map((line) => line.id), contents: lineItems, order_id: String(shopifyOrder.id) } }], ...(testEventCode ? { test_event_code: testEventCode } : {}) }; const response = await fetch( `https://graph.facebook.com/${META_API_VERSION}/${META_PIXEL_ID}/events?access_token=${META_CAPI_TOKEN}`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(body) } ); if (!response.ok) { throw new Error(`Meta CAPI error: ${response.status} ${await response.text()}`); } return response.json(); } ``` In production, place this behind a queue and retry policy, verify Shopify webhook signatures, look up the authoritative order server-side, retain the original `event_id` on retries, and log Meta’s response without logging raw customer details. Meta’s CAPI schema requires `event_name`, `event_time`, `user_data`, and `action_source`; it supports `test_event_code` for test events. ([github.com](https://github.com/facebookincubator/Facebook-Server-Side-API-Swagger/blob/main/server-side-api.yaml)) --- ## 6. Validate end to end before scaling spend Do not judge campaign performance until the event implementation passes a controlled test. ### A. Preflight checks - [ ] One intended Meta pixel/dataset is connected. - [ ] No legacy Pixel snippet remains in theme code or GTM. - [ ] The Arc Clip Lamp is available in the Meta catalog. - [ ] Event `content_ids` match the catalog’s item-ID strategy. - [ ] Browser `Purchase` and server `Purchase` use the same `event_id` if using custom CAPI. - [ ] The server has a persistent idempotency/event ledger. - [ ] Consent behavior has been tested for the intended markets. ### B. Run a full test journey Use a Shopify test payment method or a controlled internal order: 1. Visit the Arc Clip Lamp product page. 2. Confirm exactly one `ViewContent`. 3. Add the lamp to cart. 4. Confirm exactly one `AddToCart`. 5. Start checkout. 6. Confirm exactly one `InitiateCheckout`. 7. Complete checkout. 8. Confirm: - one browser `Purchase` - one server `Purchase`, if CAPI is enabled - the same `event_name` and `event_id` on the paired custom implementation - a final value, currency, line items, and order ID matching Shopify ### C. Use Meta Events Manager In Events Manager: - Use **Test Events** while implementing custom CAPI. - Add the Test Events code as `test_event_code` to CAPI requests. - Inspect browser and server arrivals separately. - Confirm the paired purchase is marked as deduplicated rather than counted twice. - Review diagnostics for missing `value`, `currency`, `content_ids`, user data, or event-match-quality issues. Meta’s API supports a `test_event_code` for server-event validation, and Meta’s documentation directs implementers to test that paired browser/server events are received and deduplicated correctly. ([github.com](https://github.com/facebookincubator/Facebook-Server-Side-API-Swagger/blob/main/server-side-api.yaml)) ### D. Reconcile after launch For the same date range and timezone: - Compare Shopify paid orders and gross sales to internal event logs. - Confirm each paid order produces no more than one accepted server-side `Purchase` in Cedar & Coil’s event ledger. - Confirm duplicate server retries are not creating extra CAPI sends. - Compare Meta-reported purchases to Shopify orders as a directional measurement check—not as an expectation of one-to-one equality. Consent choices, browser constraints, attribution windows, and platform reporting rules will cause differences. Do not promise or plan around a fixed attribution-recovery percentage. Treat CAPI as a resilience and data-quality layer whose real effect must be measured in Cedar & Coil’s own implementation. --- ## 7. Consent and compliance note This is an implementation guide, not legal advice. Cedar & Coil should have counsel review its practices for the jurisdictions it targets. ### Operating rules 1. **Honor consent before marketing tracking where required.** Do not fire the Meta Pixel or send CAPI marketing data for a visitor who has not granted required consent or who has opted out. 2. **Make the privacy notice specific.** Explain that Cedar & Coil uses Meta business tools, including browser and server-side conversion measurement, and describe the categories of data shared and the purpose: advertising measurement, attribution, and ad optimization. 3. **Use Shopify’s customer-privacy controls.** Shopify Web Pixels can be configured with customer privacy settings, and Shopify’s pixel framework can defer execution until consent is available in consent-required regions. ([shopify.dev](https://shopify.dev/docs/apps/build/marketing/pixels)) 4. **Send only necessary, lawfully collected customer information.** Hash matching fields properly, protect access tokens and raw customer data, set retention limits, and do not use data fields unrelated to advertising measurement. 5. **Respect opt-outs and applicable data-processing rules.** Build consent state into the event pipeline—not merely the browser tag. A server webhook may know an order was paid, but that does not automatically mean Cedar & Coil may send that shopper’s information to Meta for ad measurement. 6. **Keep one source of truth for configuration.** Document the selected data-sharing level, pixel ID, catalog ID strategy, consent logic, event schema, and owner for changes. This reduces accidental duplicate tracking when agencies, apps, or theme updates are introduced later. Shopify emphasizes that merchants control how customer information is shared through Meta data-sharing settings and are responsible for keeping their privacy policy current. ([help.shopify.com](https://help.shopify.com/en/manual/promoting-marketing/analyze-marketing/meta-data-sharing))
Score the judge's verdict, criterion by criterion11/11 criteria passed
RequirementVerdictEvidence
architecture
The guide recommends browser Pixel plus server-side Conversions API with deduplication and explains why both are needed under browser privacy limits.
✓Section 1 explicitly recommends Pixel + CAPI with shared event_id/event_name and explains browser loss reasons (ad blockers, privacy controls) as why both are needed.
events_mapped
All four standard events (ViewContent, AddToCart, InitiateCheckout, Purchase) are covered with key parameters, including value, currency, and content_ids on Purchase.
✓Section 2 provides a table and code blocks for all four events with value, currency, content_ids, and Purchase includes order_id/content_ids as required.
code_sketch
A concrete server-side Purchase event code sketch or request example is included showing event_name, event_time, event_id, action_source, and a user_data block.
✓The sendPurchaseToMeta function includes event_name, event_time, event_id, action_source: 'website', and a user_data object.
validation
End-to-end validation is described using Meta's Events Manager test events tool and an explicit check that duplicate browser/server events are being deduplicated.
✓Section 6C instructs using Meta Events Manager Test Events and explicitly says to 'Confirm the paired purchase is marked as deduplicated rather than counted twice.'
sources_defined
For each event it is clear where it fires (browser vs server) and what the source of truth is (e.g. Purchase from the Shopify order webhook/server, not only the thank-you page).
✓The guide states 'Retrieve final commerce values from Shopify's server-side order data. Do not trust a browser-posted price...' and recommends a verified Shopify order webhook/Admin API lookup as the Purchase source of truth rather than the thank-you page.
limits_stated
Limitations are stated honestly: no promised attribution-recovery percentages, and consent/regional rules are noted as constraints on what may be sent.
✓The response explicitly states 'Do not promise or plan around a fixed attribution-recovery percentage' and dedicates Section 7 to consent gating as a hard constraint on sending data.
dedup_correct
Deduplication is technically correct: the same event_id and event_name sent on both the Pixel and CAPI event so Meta drops the duplicate; not a vague mention.
✓Section 3 specifies sending the same event_name and event_id on both Pixel and CAPI events so Meta treats them as duplicates and discards the later copy.
event_id_retry_stability
The event_id is generated or derived once per commerce event, shared by browser and server, and reused unchanged on webhook retries or order updates; a new random suffix per send or retry fails.
✓The guide states 'Do not change an event ID during retries. Retries must reuse the original ID' and uses a deterministic ID derived from the Shopify order ID (`purchase:<order-id>`).
event_time_stable
The server Purchase event uses the purchase/order occurrence timestamp in Unix seconds and preserves it across retries; using the current send or retry time fails.
✓The code computes event_time as `Math.floor(new Date(shopifyOrder.processed_at).getTime() / 1000)`, deriving it from the order's occurrence timestamp rather than send time, making it stable across retries.
pii_hashing
Customer data handling is correct: personally identifiable fields (e.g. email) are normalized (trimmed, lowercased) and SHA-256 hashed before sending in user_data.
✓The normalization table (trim/lowercase email, digits-only phone) precedes SHA-256 hashing shown in the sha256() code example for em and ph fields.
actionable_path
The recommended Shopify path is decisive and executable for a small DTC store (a clear recommendation with concrete setup steps, not an undifferentiated list of options).
✓The guide gives a decisive recommendation ('Start with Shopify's native Facebook & Instagram by Meta sales channel using Enhanced or Maximum data sharing') with concrete numbered setup steps for a small DTC store.