← Run 20261118-011513-b34a399f
Shopify to Meta ads conversion tracking implementation
task shopify-meta-capiNov 18, 2026Models on marketing tasks Model only

Answers & verdicts

GPT-6.2 Astra high effort

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.
✓ Attempt 1
Answer · attempt 1 the model's full response$0.66 · 98.4s · 4.7k tok
# Cedar & Coil | Draft Shopify → Meta tracking guide ## 1. Recommended architecture: Pixel + Conversions API **Use Shopify’s native Facebook & Instagram by Meta sales channel for the first implementation.** Send browser events through the Meta Pixel and send `Purchase` from Shopify to the same Meta dataset through the Conversions API (CAPI). The acceptance test is simple: **one eligible Shopify order should produce one counted Purchase**, whether Meta receives the browser copy, the server copy, or both. ([help.shopify.com](https://help.shopify.com/en/manual/promoting-marketing/analyze-marketing/meta-data-sharing?r=ecm-bfs&utm_source=openai)) The Pixel observes actions such as viewing the Arc Clip Lamp and adding it to a cart, with the browser context available at that moment. But a blocker can prevent a Pixel request, and Shopify’s browser-side checkout completion event might never fire if the confirmation page fails to load. A server event sourced from the Shopify order does not depend on that page. Keep both paths: the browser supplies useful context; the server supplies an independent purchase signal. Neither guarantees that Meta can attribute an order to an ad. ([help.shopify.com](https://help.shopify.com/en/manual/promoting-marketing/analyze-marketing/meta-data-sharing?r=ecm-bfs&utm_source=openai)) ## 2. Standard events and parameters Use the exact event names below. Put business parameters in the Pixel’s event-data object and in CAPI’s `custom_data`. Use numeric amounts in **major currency units** (`68.00`, not `6800` or `"$68"`) and the actual three-letter checkout currency. Look up the lamp’s item ID in the connected Meta catalog; don’t assume its product title, SKU, or bare Shopify variant ID is the catalog ID. Use `content_type: "product"` for individual catalog items. ([developers.facebook.com](https://developers.facebook.com/documentation/meta-pixel/reference)) | Meta event | Shopify trigger for a custom build | Key parameters | |---|---|---| | `ViewContent` | `product_viewed` on the lamp detail page | `content_ids: [catalogItemId]`, `content_type`, displayed unit `value`, `currency`. For one full-price lamp displayed in USD: `68.00`, `USD`. | | `AddToCart` | `product_added_to_cart`; use a successful addition, not just a button click | `content_type`, `contents: [{id: catalogItemId, quantity: qtyAdded}]`, `value` of the items **just added**, `currency`. | | `InitiateCheckout` | `checkout_started`; not every checkout step | `content_ids` for the checkout lines, `num_items` as the sum of quantities, checkout `value` at that point, `currency`. | | `Purchase` | `checkout_completed` in the browser; corresponding confirmed online-store order on the server | **`value`, `currency`, `content_ids`** for the items actually purchased; also `content_type`. Use the final Shopify order total in the buyer’s currency, not the lamp’s list price. | Meta requires `value` and `currency` for `Purchase`; make `content_ids` part of Cedar & Coil’s own purchase contract so the sale can be tied to the catalog. Both copies must use the same total after discounts and the same treatment of shipping, taxes, and duties. A two-lamp or discounted order is a better test of this than a single $68 lamp. ([developers.facebook.com](https://developers.facebook.com/documentation/meta-pixel/reference)) ## 3. Exactly how deduplication works Meta’s recommended method matches **the same dataset/pixel ID, event name, and event ID**. The two copies must arrive within **48 hours** of the first receipt. For one purchase, the browser and server should send the following pair; `purchaseData` contains the parameters from section 2. ([developers.facebook.com](https://developers.facebook.com/documentation/ads-commerce/conversions-api/deduplicate-pixel-and-server-events)) ```js // Browser: eventID is in the fourth argument, not inside purchaseData. fbq("track", "Purchase", purchaseData, {eventID: "cc:purchase:1042"}); // Corresponding CAPI event fields: // event_name: "Purchase", event_id: "cc:purchase:1042" ``` For a custom build, derive the purchase ID from the **same canonical Shopify order ID** on both sides. If one side receives `gid://shopify/Order/1042` and the other receives `1042`, normalize before prefixing. A second order gets a new ID. For a cart addition or view sent both ways, generate an ID once per action and pass it to both senders; two genuine additions need two IDs. A customer ID identifies a person, and `content_ids` identifies merchandise—neither identifies this particular purchase. ([developers.facebook.com](https://developers.facebook.com/documentation/ads-commerce/conversions-api/parameters/server-event)) Send promptly. If only the server copy arrives, there is no duplicate to discard. If a webhook is redelivered, don’t create a fresh conversion: use a durable send record keyed by order and event, retain the original ID and event time on retries, and don’t resend an acknowledged purchase. Meta’s cross-channel deduplication is not a substitute for this safeguard. ([developers.facebook.com](https://developers.facebook.com/documentation/ads-commerce/conversions-api/deduplicate-pixel-and-server-events)) ## 4. Prepare customer information before server transmission Only use fields authorized for advertising measurement. Put them in `user_data`, not `custom_data`, URLs, or event IDs. For a direct CAPI request: ([developers.facebook.com](https://developers.facebook.com/documentation/ads-commerce/conversions-api/parameters/customer-information-parameters)) | Field | Preparation | |---|---| | Email `em`; phone `ph` | Trim and lowercase email. Parse phone numbers using the known country and output digits including the country code, without `+`, punctuation, or a domestic trunk prefix. Hash each normalized value **once** with unsalted SHA-256; send the lowercase hex digest. Never hash an empty value. ([developers.facebook.com](https://developers.facebook.com/documentation/ads-commerce/conversions-api/parameters/customer-information-parameters)) | | Optional names, location, `external_id` | If used, apply Meta’s field-specific normalization and hashing rules to names, city, state, postal code, and country. For example, normalize United States to `us` before hashing. Meta recommends hashing `external_id`; keep its representation consistent across channels. Don’t pre-hash a second time if your SDK already handles it. ([developers.facebook.com](https://developers.facebook.com/documentation/ads-commerce/conversions-api/parameters/customer-information-parameters)) | | `fbp`, `fbc`, `client_ip_address`, `client_user_agent` | **Do not hash.** Use genuine, permitted browser values: `_fbp` for `fbp`; `_fbc` or a correctly formatted value from an observed Meta `fbclid` for `fbc`. Never invent a click ID for direct traffic. Use the shopper’s actual IP and user agent, not the webhook sender’s. Meta requires the client user agent for website events; flag missing required context rather than substituting server values. ([developers.facebook.com](https://developers.facebook.com/documentation/ads-commerce/conversions-api/parameters/fbp-and-fbc)) | ## 5. Shopify setup: native versus custom **Native — recommended for Cedar & Coil.** This avoids maintaining a webhook service, token, retry queue, and browser/server ID mapping for a single-product store. ([help.shopify.com](https://help.shopify.com/en/manual/promoting-marketing/analyze-marketing/meta-data-sharing?r=ecm-bfs&utm_source=openai)) 1. In Shopify admin, go to **Settings → Sales channels → Shopify App Store**. Add **Facebook & Instagram by Meta**, start setup, and connect Cedar & Coil’s Meta business assets. Confirm that the intended ad account can use the selected dataset and that the connected catalog contains the lamp. ([help.shopify.com](https://help.shopify.com/en/manual/online-sales-channels/social-commerce/facebook-instagram-by-meta/setup?utm_source=openai)) 2. Open **Sales channels → Facebook & Instagram → Settings → Data sharing settings** (also labeled **Share data settings**). Enable customer data sharing, select the pixel by ID, and confirm. **Enhanced** is a reasonable starting point after privacy review: Shopify documents Pixel + server-side `Purchase` for both **Enhanced** and **Maximum**. **Standard** is browser-only. Don’t assume the channel sends all three upper-funnel events server-side; inspect their actual connection methods in Events Manager. ([help.shopify.com](https://help.shopify.com/en/manual/promoting-marketing/analyze-marketing/meta-data-sharing?r=ecm-bfs&utm_source=openai)) 3. Give the native integration sole ownership of these Meta events. Audit theme code, tag-manager tags, Shopify custom pixels, and other tracking apps for an existing sender. Remove overlapping sends; **do not install the custom sketch below alongside the native integration**. ([help.shopify.com](https://help.shopify.com/en/manual/promoting-marketing/analyze-marketing/meta-pixel)) **Custom — choose this if you need a purchase definition or data controls the channel cannot provide.** Subscribe to Shopify Customer Events for the browser triggers in section 2. For the server, subscribe to order creation for a *confirmed checkout* definition; if the business counts only captured payments, use a *paid-order* trigger and don’t send the browser `Purchase` for pending payments. Verify Shopify’s webhook signature against the raw body, filter to eligible online-store orders, and enqueue once per order. Join the order to its permitted checkout context and consent record without depending on a final-page callback. ([shopify.dev](https://shopify.dev/docs/apps/build/marketing/pixels?utm_source=openai)) **Server-side Purchase request sketch (Python, custom path only).** Here `p` is a validated order record, `ctx` is permitted shopper context, and `may_share` checks the recorded permission and any later withdrawal. Keep the CAPI token in a server secret store and pin a supported Graph API version. The website source URL should identify the real checkout page without exposing private checkout tokens or personal data. ([developers.facebook.com](https://developers.facebook.com/documentation/ads-commerce/conversions-api/using-the-api)) ```python import hashlib, json, os import requests def send_purchase(p, ctx, may_share, test_code=None): if not may_share(p): return "suppressed" user = {"client_user_agent": ctx["shopper_user_agent"]} email = (ctx.get("email") or "").strip().lower() if email: user["em"] = [hashlib.sha256(email.encode("utf-8")).hexdigest()] for key in ("fbp", "fbc", "client_ip_address"): if ctx.get(key): user[key] = ctx[key] event = { "event_name": "Purchase", "event_id": f"cc:purchase:{p['canonical_order_id']}", "event_time": p["purchase_unix_seconds"], # occurrence, not delivery time "action_source": "website", "event_source_url": ctx["safe_checkout_url"], "user_data": user, "custom_data": { "value": p["numeric_final_total"], "currency": p["buyer_currency"], "content_type": "product", "content_ids": p["catalog_item_ids"], }, } form = {"data": json.dumps([event]), "access_token": os.environ["META_CAPI_TOKEN"]} if test_code: form["test_event_code"] = test_code # QA dataset only url = (f"https://graph.facebook.com/{os.environ['META_GRAPH_VERSION']}" f"/{os.environ['META_PIXEL_ID']}/events") response = requests.post(url, data=form, timeout=10) response.raise_for_status() if response.json().get("events_received") != 1: raise RuntimeError("Purchase not acknowledged") return "acknowledged" ``` Have the worker persist the acknowledgment, retry transient failures with backoff and the **same** event ID, and surface invalid payloads or expired credentials for repair. An acknowledgment verifies receipt—not deduplication, matching, or ad attribution. ([developers.facebook.com](https://developers.facebook.com/documentation/ads-commerce/conversions-api/using-the-api)) ## 6. Validate end to end before scaling spend Use an isolated test store/dataset where possible. In **Meta Events Manager → Data Sources → selected pixel → Test Events**, open the test storefront. For custom CAPI tests, pass the displayed `test_event_code` at request level and remove it for production. **The code is not a sandbox:** Meta says tagged events can still be used for measurement. For a native integration that doesn’t expose that field, inspect **Overview → event details → connection method and Event Deduplication** rather than adding a second sender. ([developers.facebook.com](https://developers.facebook.com/documentation/ads-commerce/conversions-api/using-the-api)) | Test | Pass condition | |---|---| | Consent granted; view lamp → add → checkout → complete | All four correctly named events appear. The purchase has the expected browser/server sources, matching event IDs, one counted conversion, and the same value, currency, and catalog IDs as the Shopify order. ([developers.facebook.com](https://developers.facebook.com/documentation/meta-pixel/reference)) | | Buy two lamps with a test discount; refresh confirmation; replay the custom webhook | The order total reflects quantity and discount. Neither refresh nor redelivery adds revenue. A **second distinct order** does create another purchase. ([help.shopify.com](https://help.shopify.com/en/manual/promoting-marketing/analyze-marketing/meta-data-sharing)) | | Consent granted, but block the Meta browser request | Complete a fresh order. The eligible server `Purchase` still arrives once. An abandoned checkout must not produce a purchase. ([help.shopify.com](https://help.shopify.com/en/manual/promoting-marketing/analyze-marketing/meta-data-sharing?r=ecm-bfs&utm_source=openai)) | | Advertising permission denied or withdrawn | Verify no disallowed browser request **and** no disallowed server send, including queued retries. A silent browser alone does not prove this test passed. ([shopify.dev](https://shopify.dev/docs/api/customer-privacy?utm_source=openai)) | **Sign-off:** Reconcile deduplicated purchase counts and values against eligible Shopify online orders for the same period, time zone, and currency. Inspect Events Manager **Diagnostics**, event freshness, deduplication, and Event Match Quality. Investigate unexplained missing or extra purchases before increasing spend. Reconcile against **received events**, not Ads Manager’s *attributed* purchases: the latter answers which orders Meta credits to ads, not how many orders Shopify recorded. ([developers.facebook.com](https://developers.facebook.com/documentation/ads-commerce/conversions-api/verifying-setup)) ## 7. Consent and compliance In **Shopify → Settings → Customer privacy**, configure the regional banner and data-sharing opt-out, and describe Meta Pixel/CAPI advertising measurement in the privacy notice. Obtain opt-in where required; honor applicable sale/sharing or targeted-advertising opt-outs, including Global Privacy Control where applicable. For custom CAPI, carry the shopper’s decision to the server and suppress the send when required permission is absent. An order or email-marketing subscription is not itself permission to share advertising data. ([help.shopify.com](https://help.shopify.com/en/manual/privacy-and-security/privacy/customer-privacy-settings/privacy-settings?utm_source=openai)) Hashing permits matching; it does **not** make the data anonymous or override a refusal. Minimize the fields sent, exclude payment details and sensitive information, keep tokens and raw customer data out of logs, and review the configuration against Meta’s Business Tools terms and the laws of the markets served. **CAPI is a fallback for a missing browser request, not for a missing permission.** ([developers.facebook.com](https://developers.facebook.com/documentation/ads-commerce/conversions-api/parameters/customer-information-parameters))
Score · attempt 1 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 recommends browser Pixel plus CAPI to the same dataset and explains that blockers or a missing confirmation page can stop the Pixel while the server order signal still arrives.
events_mapped
All four standard events (ViewContent, AddToCart, InitiateCheckout, Purchase) are covered with key parameters, including value, currency, and content_ids on Purchase.
✓The section 2 table covers ViewContent, AddToCart, InitiateCheckout and Purchase with key parameters, and Purchase explicitly lists value, currency and content_ids.
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 send_purchase sketch builds an event with event_name, event_id, event_time, action_source "website" and a user_data block, then POSTs it to the Graph API events endpoint.
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 uses Events Manager Test Events with test_event_code and checks 'matching event IDs, one counted conversion' plus Event Deduplication details, including refresh and webhook replay tests.
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).
✓Purchase is defined as 'checkout_completed in the browser; corresponding confirmed online-store order on the server', and the other events are tied to Shopify Customer Events as 'browser triggers in section 2'.
limits_stated
Limitations are stated honestly: no promised attribution-recovery percentages, and consent/regional rules are noted as constraints on what may be sent.
✓No recovery percentages are given, it states 'Neither guarantees that Meta can attribute an order to an ad', and section 7 treats consent and regional rules as constraints on sending ('CAPI is a fallback for a missing browser request, not for a missing permission').
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.
✓It specifies matching on the same dataset ID, event name and event ID, with the example fbq eventID "cc:purchase:1042" paired with CAPI event_name "Purchase" and event_id "cc:purchase:1042".
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 from the canonical Shopify order ID on both sides, and the guide says to 'retain the original ID and event time on retries' and 'retry transient failures with backoff and the same event 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 uses p["purchase_unix_seconds"] with the comment 'occurrence, not delivery time', and the guide says to retain the original event time on 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.
✓Email is stripped and lowercased then SHA-256 hashed once in both the section 4 table and the code, while fbp, fbc, IP and user agent are correctly left unhashed.
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).
✓It decisively recommends the native Facebook & Instagram by Meta channel for Cedar & Coil and gives numbered admin steps, with custom described as an alternative only when native controls are insufficient.
✗ Attempt 2
Answer · attempt 2 the model's full response$0.67 · 106.1s · 5.2k tok
# Cedar & Coil | Shopify → Meta conversion tracking **Draft implementation guide.** For this small DTC store, use the native **Facebook & Instagram by Meta** sales channel with **Enhanced** data sharing, subject to privacy review. It provides the browser Pixel and a server-side `Purchase` without a custom service to maintain. The acceptance test is simple: **one eligible Shopify order should produce one Meta `Purchase` at the correct value—even if Meta receives it twice.** No campaign needs to run to test this. ([help.shopify.com](https://help.shopify.com/en/manual/promoting-marketing/analyze-marketing/meta-data-sharing?utm_source=openai)) ## 1. Architecture: browser Pixel + server-side Conversions API - **Browser path:** The Meta Pixel records actions as the shopper views the lamp, adds it to the cart, starts checkout, and completes the purchase. It has browser context, including click and browser identifiers when available and permitted. A blocked script or a confirmation page that never loads can interrupt this path. ([help.shopify.com](https://help.shopify.com/en/manual/promoting-marketing/analyze-marketing/meta-data-sharing?utm_source=openai)) - **Server path:** Shopify sends the purchase to the **same Meta pixel/dataset** through the Conversions API (CAPI). This delivery does not depend on the shopper’s browser making a request to Meta. Both paths report the same sale, not two different kinds of sale. ([help.shopify.com](https://help.shopify.com/en/manual/promoting-marketing/analyze-marketing/meta-data-sharing?utm_source=openai)) Shopify explicitly documents server-side **`Purchase`** for Enhanced and Maximum sharing. It lists all four funnel events below as Pixel events. Do not assume the native channel also sends the first three through CAPI; check the connection method for each event in Events Manager. A server event can improve delivery resilience without guaranteeing an ad match or attribution. ([help.shopify.com](https://help.shopify.com/en/manual/promoting-marketing/analyze-marketing/meta-data-sharing?utm_source=openai)) ## 2. Standard events and parameters Use numeric monetary values in **major currency units** (`68.00`, not `6800` or `"$68"`), paired with the actual three-letter currency code. Use catalog item IDs exactly as they appear in Meta Commerce Manager; do not assume a Shopify SKU, variant ID, and Meta catalog ID are interchangeable. For item-level IDs use `content_type: "product"`. On CAPI, put these commerce fields in `custom_data`. ([developers.facebook.com](https://developers.facebook.com/documentation/meta-pixel/reference)) | Meta event | Shopify action | Parameters to send or verify | |---|---|---| | `ViewContent` | Shopper views the Arc Clip Lamp product page (`product_viewed`). | `content_ids`: viewed item; `content_type`; `value`: displayed unit price; `currency`. Example: `68.00`, `USD` for the lamp at its stated US price. | | `AddToCart` | The add succeeds (`product_added_to_cart`), not merely a button click. | `content_ids`: item added; `content_type`; `contents`: item ID and quantity added; `value`: value **added by this action**, not the whole cart; `currency`. | | `InitiateCheckout` | Shopper enters checkout (`checkout_started`). | `content_ids`: checkout items; `num_items`: total units; `value`: checkout total at that point; `currency`. | | `Purchase` | Shopper completes the order (`checkout_completed` on the browser). | **`value`**: actual Shopify order total; **`currency`**: the currency of that total; **`content_ids`**: all purchased catalog item IDs. Include `content_type`. On CAPI, `order_id` is useful for reconciliation but does not replace `event_id`. | These mappings use Shopify’s customer events and Meta’s standard event definitions. `value` and `currency` are required for `Purchase`; make `content_ids` part of Cedar & Coil’s purchase specification as well. Do **not** hard-code $68 into `Purchase`: quantities, discounts, taxes, shipping, and currency can change the total. Compare both copies against the same checkout total, not one against merchandise subtotal and the other against total paid. ([shopify.dev](https://shopify.dev/docs/api/web-pixels-api/standard-events)) ## 3. Exactly how deduplication works Meta’s recommended key is **the same event name and the same event ID, delivered to the same pixel/dataset**. The field spelling and placement differ. For example, for one illustrative order: ([developers.facebook.com](https://developers.facebook.com/documentation/ads-commerce/conversions-api/deduplicate-pixel-and-server-events)) ```js // Browser: eventID is in the FOURTH argument, not in the commerce fields. fbq("track", "Purchase", purchaseCommerceFields, {eventID: "cc:purchase:12345"}); // CAPI: fields on the event itself, not inside custom_data or user_data. // { event_name: "Purchase", event_id: "cc:purchase:12345", ... } ``` Meta documents a **48-hour window** for matching copies. Send them promptly with consistent values and IDs; do not rely on one copy correcting the other. If only the server copy arrives, it can stand alone. Email hashes help match a shopper, while `content_ids` identify products; neither is the event ID in this design. ([developers.facebook.com](https://developers.facebook.com/documentation/ads-commerce/conversions-api/parameters/server-event)) **Native channel:** let it manage the IDs; verify the result rather than adding another tag. **Custom build:** derive the purchase ID from the same canonical Shopify order ID on both paths—normalize a GraphQL ID and a numeric webhook ID to the same string. For a repeatable action such as `AddToCart`, generate an ID once **per successful add** and pass it to both senders. A second genuine add gets a new ID; a webhook retry keeps the original ID and event time. Also enforce one server send record per order so a late replay cannot become a new purchase. ([developers.facebook.com](https://developers.facebook.com/documentation/ads-commerce/conversions-api/parameters/server-event)) ## 4. Prepare customer information before sending Put only permitted matching fields in CAPI `user_data`. For a direct API call: ([developers.facebook.com](https://developers.facebook.com/documentation/ads-commerce/conversions-api/parameters/customer-information-parameters)) | Field | Preparation | |---|---| | `em` | Trim surrounding whitespace, lowercase, then SHA-256 hash the normalized email once. Send the hexadecimal digest. | | `ph` | Parse with the correct country context. Normalize to country code plus national number, digits only, without `+`, punctuation, or a dialing prefix. Then SHA-256 hash once. Omit an ambiguous number rather than guessing. | | Name or address matching fields, if used | Apply Meta’s field-specific normalization, then SHA-256 hash each field separately. Hash a stable `external_id` consistently if using it; Meta recommends hashing it. | | `client_ip_address`, `client_user_agent`, `fbp`, `fbc` | **Do not hash.** Use the shopper’s actual IP and user agent—not those of Shopify’s webhook or your worker. Use genuine `_fbp` and `_fbc` values when available and permitted. Only construct `fbc` from an actual observed `fbclid`; never invent a click ID. | Use unsalted SHA-256 for matching, not a password hash. Do not double-hash fields if the SDK already hashes them. Omit unavailable optional fields instead of hashing empty strings. For website CAPI events, also supply `action_source: "website"`, the shopper’s `client_user_agent`, and the actual event page URL sanitized of personal information and checkout secrets. ([developers.facebook.com](https://developers.facebook.com/documentation/ads-commerce/conversions-api/parameters/customer-information-parameters)) ## 5. Shopify setup: native versus custom ### Recommended: native sales channel 1. In Shopify admin, go to **Settings → Sales channels → Shopify App Store**. Add **Facebook & Instagram by Meta**, start setup, and connect Cedar & Coil’s business portfolio, Page, and intended ad account. Use an account with the necessary asset permissions. ([help.shopify.com](https://help.shopify.com/en/manual/online-sales-channels/social-commerce/facebook-instagram-by-meta/setup?utm_source=openai)) 2. Go to **Sales channels → Facebook & Instagram → Settings → Data sharing settings** (also labeled **Share data settings**). Enable customer data sharing, select the intended pixel, and confirm. Record its numeric ID and verify it against the data source in Meta Events Manager. ([help.shopify.com](https://help.shopify.com/en/manual/promoting-marketing/analyze-marketing/meta-data-sharing?utm_source=openai)) 3. Select **Enhanced** if approved: **Standard** is Pixel-only; **Enhanced** adds CAPI `Purchase`; **Maximum** also uses CAPI and includes additional Meta advertising technology. Maximum is not necessary merely to obtain a server-side purchase. ([help.shopify.com](https://help.shopify.com/en/manual/promoting-marketing/analyze-marketing/meta-data-sharing?utm_source=openai)) 4. Audit `theme.liquid`, **Settings → Customer events**, tag-manager containers, legacy checkout scripts, and other tracking apps. Disable overlapping Meta senders before testing. **Do not deploy the custom request below alongside the native purchase integration.** ([help.shopify.com](https://help.shopify.com/en/manual/promoting-marketing/analyze-marketing/meta-pixel/?utm_source=openai)) ### Custom alternative: when the store needs different purchase logic A custom integration makes sense if, for example, Cedar & Coil needs `Purchase` to mean **payment confirmed**, including delayed payments. Use **Settings → Customer events → Add custom pixel** for browser subscriptions. On the backend, subscribe to Shopify’s `orders/paid` webhook, verify its HMAC over the raw body, filter to eligible online-store orders, and queue one record per order. Under this definition, send the browser `Purchase` only when payment is confirmed; if the shopper leaves while payment is pending, let the later server event stand alone. The trade-off is ownership of consent, ID mapping, credentials, retries, and monitoring. ([help.shopify.com](https://help.shopify.com/en/manual/promoting-marketing/pixels/custom-pixels/manage?utm_source=openai)) For permitted orders, join checkout context and the privacy decision to the order internally—for example, via Shopify’s checkout token. Do **not** send that token to Meta. Generate a CAPI credential under **Events Manager → data source → Settings → Conversions API → Generate access token**. Store it in a server-side secret manager, never in Liquid, browser JavaScript, or a public tag container. ([shopify.dev](https://shopify.dev/changelog/posts/removed-checkout-id-from-checkouts-and-orders-webhooks?utm_source=openai)) **Server-side `Purchase` request sketch — custom path only.** `order` below is a validated internal record built from Shopify, not a browser-supplied price. `ctx` contains only approved shopper context. The endpoint uses a pinned, supported Graph API version. ([developers.facebook.com](https://developers.facebook.com/documentation/ads-commerce/conversions-api/using-the-api)) ```python import hashlib, json, os import requests def send_purchase(order, ctx): # Check permission at the event AND again before delivery or retry. if not (ctx["allowed_at_event"] and ctx["allowed_now"]): return user = {"client_user_agent": ctx["shopper_user_agent"]} email = (order.get("permitted_email") or "").strip().lower() if email: user["em"] = [hashlib.sha256(email.encode("utf-8")).hexdigest()] for key in ("client_ip_address", "fbp", "fbc"): if ctx.get(key): user[key] = ctx[key] # genuine, permitted values; unhashed oid = order["canonical_order_id"] # same string used by the browser event = { "event_name": "Purchase", "event_id": f"cc:purchase:{oid}", "event_time": order["paid_at_unix_seconds"], # not retry time "action_source": "website", "event_source_url": ctx["sanitized_checkout_url"], "user_data": user, "custom_data": { "order_id": oid, "value": float(order["presentment_total"]), "currency": order["presentment_currency"], "content_type": "product", "content_ids": order["catalog_item_ids"], # array of strings }, } url = (f"https://graph.facebook.com/{os.environ['META_GRAPH_VERSION']}" f"/{os.environ['META_PIXEL_ID']}/events") form = {"data": json.dumps([event]), "access_token": os.environ["META_CAPI_TOKEN"]} if ctx.get("test_event_code"): # isolated QA dataset only form["test_event_code"] = ctx["test_event_code"] response = requests.post(url, data=form, timeout=10) response.raise_for_status() if response.json().get("events_received") != 1: raise RuntimeError("Meta did not acknowledge the purchase") ``` Have the queue mark the record delivered only after acknowledgment. Retry transient failures with backoff and the **same** event ID and timestamp; route invalid payloads or credentials for review rather than retrying indefinitely. Log status and diagnostic IDs, not request bodies, tokens, or customer data. An API acknowledgment is a delivery check—not proof of deduplication or attribution. ([developers.facebook.com](https://developers.facebook.com/documentation/ads-commerce/conversions-api/using-the-api)) ## 6. Validate end to end before scaling spend Use a test store or isolated dataset and Shopify’s test payment gateway. In Meta, open **Events Manager → Data Sources → intended pixel → Test Events**. For custom CAPI, put `test_event_code` at the **request level**, alongside `data`; remove it for production. A test code is **not** a sandbox: Meta says those events are still processed. For the native channel, inspect its delivery in Events Manager rather than adding a custom sender just to attach a code. ([help.shopify.com](https://help.shopify.com/en/manual/checkout-settings/test-orders/payments-test-mode?utm_source=openai)) | Test | Pass condition | |---|---| | **Normal, permitted checkout** | View the lamp, add it, start checkout, and complete a test order. Verify the four exact event names. For `Purchase`, inspect browser/server connection methods, matching IDs, and deduplication. Two received copies must represent **one** purchase; raw receipt counts alone do not prove that. ([developers.facebook.com](https://developers.facebook.com/documentation/ads-commerce/conversions-api/deduplicate-pixel-and-server-events)) | | **Money and catalog** | Test one lamp, then a separate order with two lamps or a discount. Each purchase matches its own Shopify total and currency; each `content_ids` entry resolves to the intended catalog item. The second order has a different event ID. ([help.shopify.com](https://help.shopify.com/en/manual/promoting-marketing/analyze-marketing/meta-data-sharing?utm_source=openai)) | | **Browser failure versus privacy refusal** | With sharing permitted, block the browser’s Meta request and complete an order: expect one server purchase. Separately, deny the applicable advertising permission or opt out: expect **neither** advertising path to send. These are different tests with opposite expected results. ([help.shopify.com](https://help.shopify.com/en/manual/promoting-marketing/analyze-marketing/meta-data-sharing?utm_source=openai)) | | **Replay and abandonment** | Refresh the confirmation page; for a custom build, also redeliver the webhook. Neither creates a new purchase. Abandon a separate checkout before purchase and confirm it produces no `Purchase`. ([shopify.dev](https://shopify.dev/docs/api/web-pixels-api/standard-events/checkout_completed?trk=article-ssr-frontend-pulse_little-text-block&utm_source=openai)) | **Sign-off:** Review Events Manager **Diagnostics** and **Event Details → Event Deduplication**, event freshness, and Event Match Quality. Match quality assesses the ability to match a person; it does not prove correct revenue or deduplication. Reconcile eligible Shopify order counts and values over the same dates, time zone, currency, and purchase definition. Compare against processed, deduplicated events—not raw receipts or Ads Manager’s *attributed* purchases. Keep spend on hold if an order doubles, values disagree, a permitted server purchase is missing, or an opted-out event leaks. ([developers.facebook.com](https://developers.facebook.com/documentation/ads-commerce/conversions-api/verifying-setup)) ## 7. Consent and compliance Configure **Shopify Settings → Customer privacy** for the regions served, disclose what is shared with Meta and why, and sync any third-party consent banner through Shopify’s Customer Privacy API. Apply marketing and sale/sharing choices to **both** delivery paths. Honor applicable opt-out signals such as Global Privacy Control; do not treat an email-marketing subscription or the act of paying as permission for ad tracking. If required permission cannot be established, suppress the event. ([help.shopify.com](https://help.shopify.com/en/manual/privacy-and-security/privacy/customer-privacy-settings/privacy-settings)) Hashing is for matching, not a substitute for permission. Minimize the fields sent, keep payment details and checkout secrets out of payloads and logs, and review Meta’s Business Tools terms and regional requirements before enabling sharing. **CAPI is a fallback for a failed browser delivery, not for a shopper’s refusal.** ([developers.facebook.com](https://developers.facebook.com/documentation/ads-commerce/conversions-api/parameters/customer-information-parameters))
Score · attempt 2 the judge's verdict, criterion by criterion10/11 criteria passed · failed: sources_defined
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 recommends browser Pixel plus server-side CAPI to the same dataset and explains that blocked scripts or an unloaded confirmation page break the browser path while server delivery doesn't depend on the browser.
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 table covers ViewContent, AddToCart, InitiateCheckout and Purchase with parameters, and Purchase lists value, currency and content_ids.
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 sketch builds an event with event_name, event_id, event_time, action_source and a user_data block, then posts it to the Graph API events endpoint.
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 uses Events Manager Test Events with test_event_code and checks Event Details → Event Deduplication and matching IDs so two copies count as one purchase.
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 native path says to verify the connection method per event, and the custom path uses the orders/paid webhook. The guide never states, for each event, whether it fires from the browser or the server or what its source of truth is, and it leaves server delivery of the first three events unresolved.
limits_stated
Limitations are stated honestly: no promised attribution-recovery percentages, and consent/regional rules are noted as constraints on what may be sent.
✓It states a server event "can improve delivery resilience without guaranteeing an ad match or attribution", gives no recovery percentages, and Section 7 treats consent and regional rules as constraints on sending.
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.
✓It specifies the same event name and event ID to the same pixel/dataset, with eventID in the fourth fbq argument and event_id at the top level of the CAPI event, plus the 48-hour window.
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 ID is derived from the canonical order ID ("cc:purchase:{oid}"), shared by both paths, and kept unchanged on webhook retries ("a webhook retry keeps the original ID and event time").
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 sketch uses order["paid_at_unix_seconds"] with the comment "not retry time", and the retry text says to reuse the same event ID and timestamp.
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 trim, lowercase and SHA-256 hash the email, specify phone normalization before hashing, and say IP, user agent, fbp and fbc are not hashed.
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).
✓It decisively recommends the native Facebook & Instagram by Meta channel, gives numbered setup steps through Enhanced data sharing, and reserves the custom build as an alternative.
✗ Attempt 3
Answer · attempt 3 the model's full response$0.60 · 104.1s · 4.8k tok
# Cedar & Coil | Shopify → Meta conversion tracking *Draft implementation guide. No campaign has launched.* ## 1. Recommended architecture: Pixel + Conversions API **Use Shopify’s native Facebook & Instagram by Meta sales channel.** Let it send browser events through the Meta Pixel and server-side `Purchase` events through the Conversions API (CAPI) to the **same Meta pixel/dataset**. Give that integration sole ownership of Meta tracking; don’t add a second purchase tag “for backup.” ([help.shopify.com](https://help.shopify.com/en/manual/promoting-marketing/analyze-marketing/meta-data-sharing?r=ecm-bfs&utm_source=openai)) The two paths answer different questions. The Pixel observes what the shopper did: viewed the lamp, added it to a cart, or started checkout. It also carries browser context useful for matching. But a blocked script or a confirmation page that never loads can prevent a browser event. The server path can report an eligible order from Shopify without depending on that last page load. When both paths report the sale, deduplication makes it **one purchase, not two**. Shopify documents server-side coverage for `Purchase`; verify rather than assume server coverage for the other three events. ([help.shopify.com](https://help.shopify.com/en/manual/promoting-marketing/analyze-marketing/meta-data-sharing?r=ecm-bfs&utm_source=openai)) ## 2. Standard events and parameters Use the following as the event contract for a custom build and the inspection checklist for the native channel. Use numeric money values in **major currency units** (`68.00`, not `6800` cents or `"$68"`), paired with the actual three-letter currency. Match product IDs to the connected Meta catalog exactly: use `content_type: "product"` for catalog item IDs or `"product_group"` for group IDs. Don’t assume the lamp’s SKU is the catalog ID. ([developers.facebook.com](https://developers.facebook.com/documentation/meta-pixel/reference)) | Meta event | When to fire | Commerce parameters to send or verify | |---|---|---| | `ViewContent` | Shopper views the Arc Clip Lamp product page (`product_viewed`). | `content_ids` for the item viewed, `content_type`, displayed unit `value`, `currency`; optionally `content_name: "Arc Clip Lamp"`. | | `AddToCart` | Lamp is successfully added (`product_added_to_cart`), not merely when the button is pressed. | Item ID and `content_type`; `contents` with `id` and added `quantity`; `value` of the **items added**, not the whole cart; `currency`. | | `InitiateCheckout` | Shopper starts checkout (`checkout_started`), not on every checkout step. | `content_ids` or `contents` for the checkout lines, `num_items` as total units, checkout `value`, `currency`. | | `Purchase` | Checkout completes and a qualifying online order exists. Once per order, not once per confirmation-page visit. | **`value`, `currency`, `content_ids`** for the purchased items, plus `content_type`. An optional `order_id` helps reconciliation. Use the same order total and currency on both paths. | These triggers map to Shopify’s customer events. Meta requires `value` and `currency` for `Purchase`; this guide also calls for `content_ids` so Cedar & Coil can verify which catalog item sold. For a one-lamp USD test order, `value: 68.00` is correct **only if the checkout total is $68.00**. Read the order total after discounts, with applicable tax, duty and shipping reflected as charged. Don’t hard-code the product price or pair a shop-currency amount with the shopper’s currency code. ([shopify.dev](https://shopify.dev/docs/api/web-pixels-api/standard-events?who=publisher&utm_source=openai)) ## 3. Exactly how deduplication works For each action sent both ways, Meta matches **the same dataset, the same case-sensitive event name, and the same event ID**. The spelling and placement differ by transport: ([developers.facebook.com](https://developers.facebook.com/documentation/ads-commerce/conversions-api/get-started)) ```js // Browser: eventID is in the FOURTH argument, not in commerceData. fbq("track", "Purchase", commerceData, { eventID: "cc:purchase:12345" }); // CAPI: at the top level of the individual event, not inside custom_data. // { event_name: "Purchase", event_id: "cc:purchase:12345", ... } ``` Meta documents a **48-hour** matching window. Send both copies promptly with complete, consistent commerce data; don’t rely on Meta combining two partial payloads. If only the server copy arrives, there is no browser duplicate to discard. An email hash identifies a *person*, and `content_ids` identify *products*; neither identifies this particular purchase. Merely including `order_id` in `custom_data` does not set `event_id`. ([developers.facebook.com](https://developers.facebook.com/documentation/ads-commerce/conversions-api/parameters/server-event)) For a **custom** build, derive the purchase ID on both paths from the same canonical Shopify order ID. For example, normalize a Shopify Order GID and its webhook numeric-ID string to the same decimal **string**, then prefix it with `cc:purchase:`. For a repeated action such as adding another lamp, use a **new** action ID and pass that one ID to both transports. Preserve the original ID and occurrence time on retries. Keep a durable unique record per purchase so a webhook redelivery can’t enqueue a second sale. With the native channel, verify its paired IDs; don’t generate a competing set. ([shopify.dev](https://shopify.dev/docs/api/web-pixels-api/standard-events/checkout_completed?utm_source=openai)) ## 4. Prepare server-side customer information Send only permitted, relevant matching data, under `user_data`. For a direct HTTP implementation: ([developers.facebook.com](https://developers.facebook.com/documentation/ads-commerce/conversions-api/parameters/customer-information-parameters)) | Field | Preparation | |---|---| | Email `em`; phone `ph` | Trim and lowercase email. Parse phone using its known country, then use digits including country code, without punctuation or domestic trunk prefix. Apply **unsalted SHA-256 once** to each normalized UTF-8 value; send lowercase hexadecimal digests. Omit missing or invalid values rather than hashing an empty string. ([developers.facebook.com](https://developers.facebook.com/documentation/ads-commerce/conversions-api/parameters/customer-information-parameters)) | | Optional name, city, state, postal code, country | Apply Meta’s **field-specific** normalization, then SHA-256 each field separately. Examples: lowercase two-letter country (`us`), lowercase US state (`ca`), first five digits of a US ZIP. For a stable merchant customer `external_id`, Meta recommends hashing and consistent formatting across channels. Don’t double-hash if the SDK already hashes for you. ([developers.facebook.com](https://developers.facebook.com/documentation/ads-commerce/conversions-api/parameters/customer-information-parameters)) | | `client_ip_address`, `client_user_agent`, `fbp`, `fbc` | **Do not hash.** Use the shopper’s real IP and browser user agent, never the webhook sender’s or worker’s. Use permitted `_fbp` and `_fbc` cookie values when available. If `_fbc` is absent, construct `fbc` only from a genuine observed `fbclid` using Meta’s format; don’t invent a click ID for an organic visit. Meta requires the client user agent for website CAPI events. ([developers.facebook.com](https://developers.facebook.com/documentation/ads-commerce/conversions-api/parameters/customer-information-parameters)) | ## 5. Shopify setup: native channel versus custom **Native — recommended for Cedar & Coil.** This is the lower-maintenance route for a small store with a standard Shopify checkout. ([help.shopify.com](https://help.shopify.com/en/manual/promoting-marketing/pixels/?utm_source=openai)) 1. Audit the theme, tag manager, **Settings → Customer events**, and other tracking apps. Remove or disable any existing sender for the same Meta events before enabling the replacement. ([help.shopify.com](https://help.shopify.com/en/manual/promoting-marketing/analyze-marketing/meta-pixel/?utm_source=openai)) 2. In Shopify admin, go to **Settings → Sales channels → Shopify App Store**. Add **Facebook & Instagram by Meta**, start setup, sign in, and connect Cedar & Coil’s business portfolio, Page and intended ad account. Confirm the catalog contains the Arc Clip Lamp. ([help.shopify.com](https://help.shopify.com/en/manual/online-sales-channels/social-commerce/facebook-instagram-by-meta/setup?utm_source=openai)) 3. Go to **Sales channels → Facebook & Instagram → Settings → Data sharing settings** (also labeled **Share data settings**). Enable customer data sharing, choose the level, connect the intended pixel and confirm. Record its numeric ID and compare it with Events Manager. **Standard** is browser-only. Shopify documents **Enhanced** and **Maximum** as including Pixel plus CAPI `Purchase`; start with **Enhanced** if approved under the store’s privacy policy. Maximum is not necessary merely to enable server-side purchase reporting. ([help.shopify.com](https://help.shopify.com/en/manual/promoting-marketing/analyze-marketing/meta-data-sharing?r=ecm-bfs&utm_source=openai)) **Custom — use instead if a tested requirement justifies it.** Examples are a headless storefront or a purchase definition the native channel cannot express. You gain control over triggers and fields, but own consent enforcement, secure credentials, retries and monitoring. Subscribe to the four Shopify customer events through a pixel managed in **Settings → Customer events**. For an order-placed definition, take the server copy from an authenticated `orders/create` webhook filtered to eligible online checkout orders—not a browser callback forwarded to a server. If the business instead measures *paid* orders, use the paid transition and don’t fire a browser `Purchase` for a still-pending payment. ([help.shopify.com](https://help.shopify.com/en/manual/promoting-marketing/pixels/?utm_source=openai)) **Server-side `Purchase` request sketch — custom route only.** Generate the token in **Events Manager → dataset/pixel → Settings → Conversions API → Set up manually**. Keep it in a server secret store. The worker below receives a validated order record after Shopify webhook signature verification and duplicate suppression. Join permitted checkout context and the privacy decision to the order before dispatch; don’t depend on a thank-you-page callback for that join. ([developers.facebook.com](https://developers.facebook.com/documentation/ads-commerce/conversions-api/get-started)) ```js // Node.js worker. o is an internal validated record, not the raw webhook. import { createHash } from "node:crypto"; const sha256 = s => createHash("sha256").update(s, "utf8").digest("hex"); async function sendPurchase(o, env) { if (o.metaSharingAllowed !== true) return; // Checked again at dispatch. const email = o.permittedEmail?.trim().toLowerCase(); const event = { event_name: "Purchase", event_id: `cc:purchase:${o.canonicalOrderId}`, // Same string as Pixel. event_time: o.orderPlacedUnixSeconds, // Original time, not retry time. action_source: "website", event_source_url: o.safeCheckoutUrl, // Actual page, no PII or secrets. user_data: { ...(email && { em: [sha256(email)] }), client_user_agent: o.buyerUserAgent, ...(o.permittedBuyerIp && { client_ip_address: o.permittedBuyerIp }), ...(o.fbp && { fbp: o.fbp }), ...(o.fbc && { fbc: o.fbc }) }, custom_data: { value: o.presentmentTotal, // Validated number, major units. currency: o.presentmentCurrency, content_type: "product", // This feed uses item-level IDs. content_ids: o.lines.map(line => line.metaCatalogItemId), order_id: o.canonicalOrderId } }; const body = { data: [event] }; if (env.IS_QA && env.TEST_EVENT_CODE) body.test_event_code = env.TEST_EVENT_CODE; const url = `https://graph.facebook.com/${env.GRAPH_VERSION}/${env.PIXEL_ID}/events`; const res = await fetch(url, { method: "POST", headers: { Authorization: `Bearer ${env.CAPI_TOKEN}`, "Content-Type": "application/json" }, body: JSON.stringify(body) }); const result = await res.json(); if (!res.ok || result.events_received !== 1) throw new Error(`Meta delivery failed: HTTP ${res.status}, code ${result.error?.code ?? "-"}`); } ``` Pin a supported Graph API version. In the queue, retry transient failures with backoff using the **same record**; route invalid payloads or authentication errors for correction rather than retrying indefinitely. Log status, event ID and any diagnostic trace ID—not tokens, customer fields or full payloads. `events_received: 1` confirms receipt of the request’s event, **not** deduplication or ad attribution. ([developers.facebook.com](https://developers.facebook.com/documentation/ads-commerce/conversions-api/using-the-api)) ## 6. Validate end to end before scaling spend Use a test store and a separate QA dataset where possible. In **Meta Events Manager → Data Sources → selected dataset → Test Events**, open the browser test and, for a custom server, put its `test_event_code` at the request’s top level. That code makes events visible for debugging; **it does not isolate them from measurement**. Remove it from production. Use Shopify’s test payment gateway or Shopify Payments test mode away from live shoppers. ([developers.facebook.com](https://developers.facebook.com/documentation/ads-commerce/conversions-api/using-the-api)) | Test | Pass condition | |---|---| | **Consented, ordinary checkout** | View the lamp, add it, begin checkout and complete the test order. Inspect all four event names in sequence. Check Pixel activity with Meta Pixel Helper and server activity in Events Manager. For `Purchase`, verify **Browser + Server**, matching IDs, and one deduplicated purchase in event details—not just two raw arrivals in Overview. ([developers.facebook.com](https://developers.facebook.com/docs/facebook-business-extension/fbe/guides/ig-migration?utm_source=openai)) | | **Money and catalog** | Try two lamps or a discount so a hard-coded `$68` fails the test. Compare both purchase copies with the Shopify order’s total and currency; resolve each `content_ids` entry against the connected catalog. Test an accelerated checkout if offered. ([developers.facebook.com](https://developers.facebook.com/documentation/meta-pixel/reference)) | | **Missing browser event and repeats** | With sharing permitted, block the browser Pixel request and place a new eligible order: expect one server `Purchase`. Then refresh a confirmation page and, for custom builds, replay the same webhook: expect no extra purchase. An abandoned checkout must not produce one. ([help.shopify.com](https://help.shopify.com/en/manual/promoting-marketing/analyze-marketing/meta-data-sharing?r=ecm-bfs&utm_source=openai)) | | **Consent denied or withdrawn** | In a region requiring opt-in, test before consent and after rejection. Also test a relevant sale/sharing opt-out. Verify that neither the browser **nor the server queue** sends a disallowed event. A silent Pixel alone is not a pass. ([shopify.dev](https://shopify.dev/docs/api/customer-privacy?utm_source=openai)) | **Sign-off:** Review Diagnostics, Event Deduplication, freshness and Event Match Quality. Reconcile eligible Shopify online orders and their values against deduplicated purchase events over the same period, time zone and currency. Investigate unexplained gaps or duplicates before scaling. Don’t use Ads Manager attributed purchases as the order ledger: receiving an event, matching it to a person and crediting it to an ad are separate outcomes. ([developers.facebook.com](https://developers.facebook.com/documentation/ads-commerce/conversions-api/verifying-setup)) ## 7. Consent and compliance Configure **Shopify → Settings → Customer privacy** for the markets served. Disclose what Cedar & Coil shares with Meta and why. Use Shopify’s banner or a consent platform integrated with its Customer Privacy API; honor required prior consent, withdrawals, applicable sale/sharing opt-outs and Global Privacy Control signals. For a custom sender, carry the marketing and sale/sharing decision through checkout to the worker. If required permission cannot be established, **do not send**. A completed order, an email-marketing opt-in, or a hashed address is not by itself permission for ad tracking. CAPI is a fallback for a missing browser signal, **not** a fallback for missing consent. ([shopify.dev](https://shopify.dev/docs/api/customer-privacy?utm_source=openai))
Score · attempt 3 the judge's verdict, criterion by criterion10/11 criteria passed · failed: sources_defined
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 recommends the Pixel plus CAPI on the same dataset with dedup, and explains that blocked scripts or an unloaded confirmation page can prevent browser events while the server path still reports the order.
events_mapped
All four standard events (ViewContent, AddToCart, InitiateCheckout, Purchase) are covered with key parameters, including value, currency, and content_ids on Purchase.
✓The Section 2 table covers ViewContent, AddToCart, InitiateCheckout and Purchase with parameters, and Purchase explicitly lists value, currency and content_ids.
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 Node.js sketch builds a Purchase event with event_name, event_id, event_time, action_source: "website" and a 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 uses Events Manager Test Events and says to verify "Browser + Server, matching IDs, and one deduplicated purchase in event details".
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 says Purchase is server-sourced from an orders/create webhook and fires once per order, but it never states browser versus server for ViewContent, AddToCart and InitiateCheckout, and it says to "verify rather than assume server coverage for the other three events".
limits_stated
Limitations are stated honestly: no promised attribution-recovery percentages, and consent/regional rules are noted as constraints on what may be sent.
✓It promises no recovery percentages and states that consent constrains sending: "If required permission cannot be established, do not send", and that CAPI is "not a fallback for missing consent".
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.
✓It specifies the same dataset, same case-sensitive event name and same event ID, with a browser fbq 4th-argument eventID example and a top-level CAPI event_id, plus the 48-hour window.
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 derives from the canonical order ID (`cc:purchase:${o.canonicalOrderId}`), is shared by both paths, and the guide says to "Preserve the original ID and occurrence time on retries" and to retry using the same record.
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 uses `event_time: o.orderPlacedUnixSeconds, // Original time, not retry time` and the guide says to preserve occurrence time on 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.
✓It says to trim and lowercase the email, then apply unsalted SHA-256 once to produce a lowercase hex digest, and the code does `sha256(email.trim().toLowerCase())`; IP, user agent, fbp and fbc are correctly left unhashed.
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).
✓It decisively recommends the native Facebook & Instagram channel with numbered steps (Settings → Sales channels, Data sharing, Enhanced level) and gives the conditions under which custom would be used instead.