← Run 20260825-064613-c5112316
Shopify to Meta ads conversion tracking implementation
task shopify-meta-capiAug 25, 2026

Answers & verdicts

GPT-5.6 Luna medium 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.006 · 51.2s · 4.6k tok
# Meta Conversion Tracking Implementation Guide for Cedar & Coil ## 1. Recommended architecture: browser Pixel plus server-side Conversions API Use both: 1. **Meta Pixel in the browser** - Captures events directly from product pages, cart, checkout, and the order confirmation page. - Provides browser context such as the current URL, referrer, and Meta cookies such as `_fbp` and `_fbc`. - Supports standard browser-side reporting and audience-building features. 2. **Meta Conversions API (CAPI) from a server or Shopify integration** - Sends events directly from Shopify or a server to Meta. - Helps when browsers block scripts, cookies, or third-party tracking. - Can include server-known order and customer data that may not be available to the browser. Browser tracking alone is vulnerable to ad blockers, cookie restrictions, browser privacy controls, and checkout/browser changes. CAPI alone may lack browser identifiers and page-level context. Sending both provides complementary signals. The architecture should be: ```text Shopify storefront / checkout ├── Meta Pixel event └── Shopify or server-side CAPI event │ └── Same event_name + event_id for events that represent the same action │ └── Meta deduplicates ``` Do not send two independent Purchase events with different IDs for the same order. --- ## 2. Standard events and required parameters Use Meta’s standard events: - `ViewContent` - `AddToCart` - `InitiateCheckout` - `Purchase` For all events, include: - `event_name` - `event_time` for CAPI - `event_source_url` for CAPI where available - `action_source: "website"` for CAPI - A unique `event_id` - `currency` - Relevant product identifiers in `content_ids` For the Arc Clip Lamp, the catalog and event payload should use the same product or variant ID format. If the catalog contains Shopify variant IDs, use those same IDs in `content_ids`. ### `ViewContent` Fire when a shopper views the Arc Clip Lamp product page. Recommended parameters: ```text content_ids: ["<shopify-variant-or-product-id>"] content_type: "product" value: 68.00 currency: "USD" ``` Use the actual displayed product price dynamically rather than hard-coding the value in production. ### `AddToCart` Fire after the item is successfully added to the cart, not merely when the button is clicked. Recommended parameters: ```text content_ids: ["<shopify-variant-or-product-id>"] content_type: "product" value: 68.00 currency: "USD" num_items: 1 ``` For multiple items, send all relevant IDs and the cart value. ### `InitiateCheckout` Fire when the shopper begins checkout. Recommended parameters: ```text content_ids: ["<shopify-variant-or-product-id>"] content_type: "product" value: <checkout-or-cart-subtotal> currency: "USD" num_items: <quantity> ``` Use a consistent definition for `value`, such as merchandise subtotal before shipping and tax, and document that definition. ### `Purchase` Fire once when the order is successfully completed. Required or strongly recommended parameters: ```text content_ids: ["<shopify-variant-id>"] content_type: "product" value: 68.00 currency: "USD" ``` Also include: ```text num_items: 1 order_id: "<shopify-order-id>" ``` For an order containing multiple products, include every purchased variant ID: ```json { "content_ids": ["variant-123", "variant-456"], "content_type": "product", "value": 136.00, "currency": "USD", "num_items": 2, "order_id": "shopify-order-1001" } ``` `Purchase.value` should match the business definition used consistently in reporting. Many stores use the final order value, while others use merchandise subtotal. Choose one and use it in both browser and server events. Do not accidentally send a dollar amount in one event and cents in another. --- ## 3. Exactly how deduplication works Meta deduplicates browser and server events when the events represent the same conversion and contain: 1. The same `event_name`, such as `Purchase` 2. The same `event_id`, such as a UUID or order-based event identifier 3. Events sent to the same Meta dataset or Pixel Example: ```text Browser Pixel: event_name = Purchase event_id = purchase-shopify-order-1001 CAPI: event_name = Purchase event_id = purchase-shopify-order-1001 ``` Meta treats these as two delivery paths for one event rather than two purchases. A practical pattern is: ```text event_id = "purchase-" + Shopify order ID ``` For non-purchase events, use a generated unique ID tied to the actual interaction: ```text event_id = "add_to_cart-" + UUID ``` The same ID must be available to both the browser and server event. For example: ```javascript const eventId = "purchase-shopify-order-1001"; fbq( "track", "Purchase", { value: 68.00, currency: "USD", content_ids: ["variant-123"], content_type: "product" }, { eventID: eventId } ); ``` The corresponding CAPI event must contain: ```json { "event_name": "Purchase", "event_id": "purchase-shopify-order-1001" } ``` Important implementation rules: - Do not generate one random ID in the browser and another random ID on the server for the same action. - Do not rely only on `order_id` unless it is formatted consistently and is unique within the dataset. - Do not send the same Purchase repeatedly from page reloads. - Store or derive a stable Purchase ID from the Shopify order ID. - If the native Shopify integration already manages Pixel/CAPI deduplication, do not add a second custom Purchase sender without coordinating event IDs. For Purchase events, use the Shopify order as the source of truth and make the server-side process idempotent. A webhook retry should not create another logical conversion. --- ## 4. Preparing customer information for server-side events CAPI can use customer information for event matching. Prepare it as follows. ### Hash standard customer identifiers Hash these values with SHA-256 before sending: - Email address - Phone number - First name - Last name - City - State or region - Postal code - Country - External customer ID, where applicable Normalize first, then hash: - Email: trim whitespace and lowercase. - Phone: convert to international E.164 format where possible, then remove formatting characters. - Country: use a consistent two-letter country code. - State and city: lowercase and remove unnecessary whitespace. - Postal code: use the format appropriate to the country. Hashing is not a replacement for consent or a guarantee of anonymity. It is an identifier format expected by Meta for these fields. ### Do not hash browser identifiers Send these in their expected form: - `_fbp` browser identifier: `fbp` - `_fbc` click identifier: `fbc` - IP address: `client_ip_address` - Browser user agent: `client_user_agent` Do not invent an `fbc` value. Send it when it was actually collected from a Meta click, commonly from the `fbclid` URL parameter. ### Example server-side `user_data` ```json { "em": ["<sha256-normalized-email>"], "ph": ["<sha256-e164-phone>"], "fn": ["<sha256-normalized-first-name>"], "ln": ["<sha256-normalized-last-name>"], "ct": ["<sha256-normalized-city>"], "st": ["<sha256-normalized-state>"], "zp": ["<sha256-normalized-postal-code>"], "country": ["<sha256-country-code>"], "external_id": ["<sha256-shopify-customer-id>"], "fbp": "<raw-fbp-value>", "fbc": "<raw-fbc-value>", "client_ip_address": "<client-ip>", "client_user_agent": "<user-agent>" } ``` Only send fields that were collected lawfully and are available. Minimize data collection, and do not send unnecessary order notes or free-form customer data. --- ## 5. Concrete Shopify setup path ### Option A: Native Meta sales channel app For a small DTC store, use Shopify’s native **Facebook & Instagram by Meta** sales channel unless there is a specific reason to build custom infrastructure. The interface names can change, but the setup generally follows this path: 1. In Shopify admin, install or open **Facebook & Instagram by Meta** under Sales channels. 2. Connect the appropriate: - Meta Business portfolio - Facebook Page, if required - Instagram account, if required - Ad account - Meta Pixel or dataset 3. Enable the highest available data-sharing setting that is legally appropriate for the store and its consent configuration. 4. Confirm that Shopify’s Meta integration is enabled for the storefront and checkout. 5. Connect or sync the Shopify product catalog. 6. Verify that the Arc Clip Lamp’s catalog ID or variant IDs match the `content_ids` used in events. 7. Review Shopify’s customer privacy and consent settings. 8. In Meta Events Manager, confirm that the dataset is receiving browser and server events. 9. Do not install an additional manually coded Pixel if Shopify is already injecting one. 10. Do not add a separate custom CAPI Purchase event unless it has been designed to deduplicate with the native integration. #### Advantages - Fastest implementation. - Shopify handles much of the Pixel and CAPI plumbing. - Better alignment with Shopify checkout and order data. - Less custom maintenance. - Lower risk of missing checkout or Purchase events. #### Limitations - Less control over custom event logic. - Event IDs and payload details may be controlled by the integration. - Debugging can require checking both Shopify and Meta diagnostics. - Advanced server-side enrichment may not be available through the standard setup. ### Option B: Custom implementation A custom implementation can use: - A manually installed Pixel or custom web pixel for browser events. - Shopify webhooks, such as order creation, for server-side Purchase events. - A server or serverless function to call the Meta Graph API. - A database or idempotency store to prevent duplicate order sends. Use this approach when Cedar & Coil needs: - Custom event schemas. - Multiple destinations beyond Meta. - Server-side order enrichment. - Fine-grained consent and routing logic. - Full control over retries, logging, and deduplication. It also creates more responsibility for: - Pixel placement. - Checkout coverage. - Consent gating. - Hashing and normalization. - API credentials. - Webhook retries. - Duplicate prevention. - API version changes. - Privacy requests and data deletion. ### Example server-side Purchase request The following is a conceptual Node.js sketch. Store the access token in a secret manager, not in Shopify theme code or browser JavaScript. ```javascript import crypto from "node:crypto"; const PIXEL_ID = process.env.META_PIXEL_ID; const META_ACCESS_TOKEN = process.env.META_CAPI_ACCESS_TOKEN; const META_API_VERSION = "vXX.X"; // Use the currently supported version function sha256(value) { return crypto .createHash("sha256") .update(value, "utf8") .digest("hex"); } function normalizeEmail(email) { return email.trim().toLowerCase(); } function normalizePhone(phone) { // In production, normalize to E.164 with a phone library. return phone.replace(/[^\d+]/g, ""); } async function sendPurchaseToMeta(order) { const eventId = `purchase-${order.id}`; const contentIds = order.lineItems.map(item => String(item.variantId || item.productId) ); const event = { event_name: "Purchase", event_time: Math.floor(Date.now() / 1000), event_id: eventId, action_source: "website", event_source_url: order.statusPageUrl, user_data: { em: [sha256(normalizeEmail(order.email))], ...(order.phone ? { ph: [sha256(normalizePhone(order.phone))] } : {}), ...(order.fbp ? { fbp: order.fbp } : {}), ...(order.fbc ? { fbc: order.fbc } : {}), ...(order.clientIp ? { client_ip_address: order.clientIp } : {}), ...(order.userAgent ? { client_user_agent: order.userAgent } : {}) }, custom_data: { value: Number(order.totalPrice), currency: order.currency, // Example: "USD" content_ids: contentIds, content_type: "product", num_items: order.lineItems.reduce( (sum, item) => sum + Number(item.quantity), 0 ), order_id: String(order.id) } }; const response = await fetch( `https://graph.facebook.com/${META_API_VERSION}/${PIXEL_ID}/events`, { method: "POST", headers: { "Content-Type": "application/json", "Authorization": `Bearer ${META_ACCESS_TOKEN}` }, body: JSON.stringify({ data: [event] // Add test_event_code here only for test traffic. }) } ); const result = await response.json(); if (!response.ok) { throw new Error(`Meta CAPI error: ${JSON.stringify(result)}`); } return result; } ``` In a production implementation: - Trigger this from a Shopify order event or webhook. - Save the order ID and event ID before or during processing. - Treat webhook retries as retries of the same event. - Do not send a new Purchase after every status-page refresh. - Use the final approved order amount and currency. - Define how refunds, cancellations, and test orders are handled. - Keep API credentials and customer data out of logs. --- ## 6. End-to-end validation before scaling spend Validate in this order. ### A. Confirm storefront event firing On the Arc Clip Lamp product page: 1. Open browser developer tools or a Meta Pixel inspection tool. 2. Confirm `ViewContent` fires once. 3. Confirm: - Correct product or variant ID - Correct value - `currency: "USD"` - Correct page URL Add the item to cart and confirm: - `AddToCart` fires only after a successful add. - Quantity and value are correct. - `content_ids` match the catalog. Begin checkout and confirm: - `InitiateCheckout` fires once per checkout initiation. - Cart contents and value are correct. ### B. Complete a test order Use Shopify’s supported test-order or payment-test process. Confirm that: - One browser `Purchase` is emitted. - One server `Purchase` is emitted. - Both have the same `event_name`. - Both have the same `event_id`. - The order ID is correct. - The amount and currency match the order. - `content_ids` match the catalog. Avoid repeatedly refreshing the order confirmation page during testing unless the implementation explicitly prevents re-sending. ### C. Use Meta Events Manager In Meta Events Manager: 1. Open the relevant dataset or Pixel. 2. Use **Test Events** to observe test traffic. 3. Check browser and server event reception. 4. Review diagnostics and warnings. 5. Confirm that duplicate browser/server Purchases are being recognized as deduplicated rather than counted as separate conversions. 6. Check event match quality and the presence of expected identifiers. 7. Confirm that the event is eligible for the intended website conversion optimization. Test with: - A product page view - An add-to-cart - A checkout initiation - A completed order - A repeat page load of the confirmation page - A webhook retry or simulated server retry ### D. Reconcile against Shopify For a controlled test period, compare: - Shopify completed orders - Server-side Purchase events - Browser Purchase events - Meta received and deduplicated event diagnostics Investigate discrepancies caused by: - Currency or unit conversion. - Tax and shipping inclusion differences. - Failed or pending orders. - Canceled orders. - Duplicate webhook processing. - Multiple Pixels or datasets. - Product versus variant ID mismatches. - Consent restrictions. - Checkout pages not receiving the intended browser event. Only after the event flow is technically consistent should Cedar & Coil use Purchase for campaign optimization or increase spend. This validation does not guarantee that every conversion will be observable or attributed by Meta. --- ## 7. Consent and compliance note Tracking must follow the laws and privacy choices applicable to the shopper’s location. Implement the Shopify customer privacy settings and, where needed, a consent management platform that: - Blocks or limits Pixel and CAPI processing until the required consent is obtained. - Passes the consent state to the server-side event pipeline. - Honors opt-outs and “sale/share” or targeted-advertising choices where applicable. - Provides a privacy notice explaining Meta Pixel and Conversions API use. - Supports deletion or access requests as required. - Retains only the customer data needed for measurement. Hashing email or phone numbers before sending does not eliminate privacy obligations. Do not send customer information when consent or another valid legal basis is absent. In regions with restricted data processing, configure the applicable Meta data-processing controls and consult qualified privacy counsel for the store’s jurisdictions.
Score · attempt 1 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 explains both browser Pixel and server-side CAPI are needed because browser tracking alone is vulnerable to ad blockers and privacy controls while CAPI alone lacks browser context, and shows an architecture diagram tying them together via shared event_id.
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 covers ViewContent, AddToCart, InitiateCheckout, and Purchase each with content_ids, value, and currency parameters, with Purchase also including content_ids for multiple items.
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 sendPurchaseToMeta function includes event_name, event_time, event_id, action_source: 'website', and a user_data block with hashed identifiers.
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 explicitly instructs using Meta Events Manager's 'Test Events' tool and to 'confirm that duplicate browser/server Purchases are being recognized as deduplicated rather than counted as separate conversions.'
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 Purchase should fire from browser and server, and explicitly says 'use the Shopify order as the source of truth and make the server-side process idempotent,' distinguishing it from repeated thank-you page loads.
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 guide states 'This validation does not guarantee that every conversion will be observable or attributed by Meta' and repeatedly ties sending of data to consent/legal basis constraints without giving any recovery percentage.
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 explains Meta deduplicates when 'the same event_name' and 'the same event_id' are sent on both browser and server events, illustrated with a concrete shared event_id example.
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 instructs deriving event_id as 'purchase-' + Shopify order ID and states 'A webhook retry should not create another logical conversion,' meaning the ID is stable across retries.
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: Math.floor(Date.now() / 1000)`, which uses the current send time rather than the order's occurrence timestamp, and no text corrects this for 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 guide specifies trimming/lowercasing email and phone normalization before SHA-256 hashing, both in the prose and in the normalizeEmail/sha256 code functions.
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).
✓Section 5 gives a decisive recommendation ('use Shopify’s native Facebook & Instagram by Meta sales channel unless there is a specific reason to build custom infrastructure') followed by a concrete numbered setup path.
✗ Attempt 2
Answer · attempt 2 the model's full response$0.005 · 43.9s · 4.2k tok
# Meta Conversion Tracking Implementation Guide for Cedar & Coil ## 1. Recommended architecture Use both: 1. **Browser-side Meta Pixel** 2. **Server-side Meta Conversions API (CAPI)** ### Recommended flow ```text Shopify storefront ├─ Browser Pixel events │ └─ ViewContent, AddToCart, InitiateCheckout, Purchase │ └─ Shopify/app/backend event data └─ CAPI events └─ Purchase, and optionally other server-observable events ``` For purchases, send the event through both paths: - The browser Pixel sends a `Purchase` event. - The server sends a matching CAPI `Purchase` event. - Both use the same `event_name` and `event_id`. ### Why both are needed The Pixel is useful for: - Capturing browser behavior in real time - Supporting retargeting and audience creation - Sending browser identifiers such as `_fbp` and `_fbc` - Providing event context such as the page URL and browser user agent CAPI is useful for: - Sending confirmed order data from Shopify’s server-side systems - Reducing dependence on browser cookies, ad blockers, and script restrictions - Preserving purchase reporting when the browser cannot reliably complete a Pixel request - Including server-side customer and order information when legally permitted CAPI does not bypass consent requirements or guarantee that every event will be attributed. It is a second delivery path that improves signal resilience. Avoid sending the same event through separate implementations unless they are deliberately deduplicated. For example, do not install the native Shopify Meta integration and also deploy an independent custom Purchase integration without coordinating event IDs. --- ## 2. Standard events and required parameters Use Meta’s standard event names exactly as shown. ### `ViewContent` Fire when a visitor views the Arc Clip Lamp product page. Recommended parameters: ```javascript { content_ids: ["ARC-CLIP-LAMP-SKU"], content_type: "product", content_name: "Arc Clip Lamp", value: 68.00, currency: "USD" } ``` Notes: - Use the Shopify product variant SKU or another stable catalog ID. - The ID must match the ID used in the Meta catalog. - `value` and `currency` are recommended even though this is not a completed transaction. ### `AddToCart` Fire when the visitor successfully adds the product to the cart. Recommended parameters: ```javascript { content_ids: ["ARC-CLIP-LAMP-SKU"], content_type: "product", content_name: "Arc Clip Lamp", contents: [ { id: "ARC-CLIP-LAMP-SKU", quantity: 1, item_price: 68.00 } ], value: 68.00, currency: "USD" } ``` For multiple quantities or products, calculate `value` as the total item value represented by the event. ### `InitiateCheckout` Fire when the customer begins checkout, not merely when they view the cart. Recommended parameters: ```javascript { content_ids: ["ARC-CLIP-LAMP-SKU"], content_type: "product", contents: [ { id: "ARC-CLIP-LAMP-SKU", quantity: 1, item_price: 68.00 } ], num_items: 1, value: 68.00, currency: "USD" } ``` Use the checkout subtotal or the agreed business definition consistently. Document whether `value` includes discounts, shipping, and tax. ### `Purchase` Fire only after Shopify confirms a successful order. Recommended parameters: ```javascript { content_ids: ["ARC-CLIP-LAMP-SKU"], content_type: "product", contents: [ { id: "ARC-CLIP-LAMP-SKU", quantity: 1, item_price: 68.00 } ], num_items: 1, order_id: "SHOPIFY-ORDER-ID", value: 68.00, currency: "USD" } ``` For `Purchase`, include at minimum: - `value` - `currency` - `content_ids` - A stable `order_id` or equivalent internal order reference - `contents` when possible Use the actual order total according to the reporting convention selected by Cedar & Coil. For example, if reporting net merchandise revenue, do not inconsistently include shipping on some events and exclude it on others. Use a real ISO currency code such as `USD`, not a currency symbol. --- ## 3. Exactly how deduplication works Meta deduplicates a browser event and a CAPI event when the two events have: 1. The same `event_name`, such as `Purchase` 2. The same `event_id`, such as `purchase_100045` Example: ```text Browser Pixel: event_name = Purchase event_id = purchase_100045 CAPI: event_name = Purchase event_id = purchase_100045 ``` Meta treats these as two delivery paths for one conversion rather than two separate purchases. ### Implementation rules - Generate one event ID for the conversion. - Use that exact ID in both the Pixel call and the CAPI request. - Do not generate one random ID in the browser and another random ID on the server. - Keep the same event name, capitalization, and event ID format. - Use a stable order-based ID for purchases where practical, such as: ```text purchase_<shopify_order_id> ``` ### Example browser event ```javascript fbq( "track", "Purchase", { value: 68.00, currency: "USD", content_ids: ["ARC-CLIP-LAMP-SKU"], content_type: "product", order_id: "100045" }, { eventID: "purchase_100045" } ); ``` ### Example server event The CAPI request must contain: ```json { "event_name": "Purchase", "event_id": "purchase_100045" } ``` For a purchase, the order ID should also be included in the event’s custom data. The order ID alone does not replace the required shared `event_id`. ### Important Shopify consideration The browser Purchase event and the server Purchase event must be connected to the same event ID. A custom implementation therefore needs a way to carry the ID from the checkout or browser into the server-side order event. Possible approaches include: - Using a supported Shopify web pixel or checkout extensibility mechanism - Persisting the event ID in checkout/cart attributes or a Shopify metafield where supported - Generating the ID deterministically from the Shopify order ID after the order is created, then ensuring the browser event uses that same value - Using an integration that already manages Pixel/CAPI deduplication Do not assume that two events with the same order number are automatically deduplicated; Meta’s deduplication key is the shared `event_id` plus `event_name`. --- ## 4. Preparing customer information for server-side events CAPI accepts customer information in `user_data`. Prepare it carefully before sending it. ### Normalize before hashing For fields that Meta expects to be hashed: 1. Trim leading and trailing whitespace. 2. Convert to lowercase where appropriate. 3. Normalize phone numbers to international format, including the country code. 4. Remove formatting characters from phone numbers. 5. SHA-256 hash the normalized value. 6. Send the hash, not the plain-text value. Common hashed fields include: - `em`: email - `ph`: phone - `fn`: first name - `ln`: last name - `ct`: city - `st`: state or region - `zp`: postal code - `country`: two-letter country code - `external_id`: a permitted internal customer identifier Example normalization: ```text Email: " Customer@Example.com " → "customer@example.com" → SHA-256 Phone: "(555) 123-4567" → "+15551234567" → SHA-256 ``` Do not hash every field indiscriminately. Browser and connection fields such as these are normally sent as values rather than SHA-256 hashes: - `client_ip_address` - `client_user_agent` - `fbp` - `fbc` ### Useful identifiers Where available and consented: - `fbp`: Meta browser identifier - `fbc`: click identifier derived from the `fbclid` URL parameter - `client_ip_address` - `client_user_agent` These should come from the same customer interaction that generated the event. Do not invent values or substitute unrelated identifiers. ### Data-quality requirements - Keep customer fields aligned with the person who placed the order. - Do not send data for customers who have not provided the required permission in applicable regions. - Do not include unnecessary sensitive information. - Secure the access token and send CAPI requests only from a server or trusted app backend. - Avoid logging raw email addresses, phone numbers, access tokens, or full customer payloads in application logs. --- ## 5. Concrete Shopify setup path ### Option A: Native Meta sales channel app For a small DTC store, this is the recommended starting point. Typical path: 1. In Shopify Admin, open **Sales channels**. 2. Add or open **Facebook & Instagram by Meta**. 3. Connect the appropriate: - Meta Business Portfolio - Facebook Page, if required - Ad account - Meta dataset/pixel - Product catalog 4. Configure Shopify’s customer privacy and data-sharing settings. 5. Select the highest data-sharing option that is legally appropriate for Cedar & Coil’s markets and consent model. 6. Verify the website domain in Meta Business Settings. 7. Confirm that the Arc Clip Lamp is included in the catalog and that its catalog ID matches the ID sent in events. 8. Allow the app to install its supported browser and server-side tracking components. 9. Place a test order and inspect the resulting events in Meta Events Manager. #### Advantages - Faster implementation - Shopify-aware checkout and order handling - Less custom maintenance - Usually manages much of the Pixel/CAPI connection - Lower risk of breaking during Shopify checkout changes #### Limitations - Less control over exact payloads and event timing - Configuration and event behavior may change with Shopify or Meta updates - Advanced deduplication and custom data requirements may not be fully exposed - You may need additional development for unusual business logic For Cedar & Coil’s single-product, small-store setup, the native integration is preferable unless there is a specific requirement it cannot satisfy. ### Option B: Custom implementation A custom setup can use: - A browser Pixel or Shopify web pixel - A server-side application - Shopify webhooks, especially an order-created or order-paid workflow - A controlled event ID stored or passed through checkout - The Meta Graph API Use this route when Cedar & Coil needs: - Custom event payloads - Multiple backends or order systems - A data warehouse-driven event pipeline - Special consent routing - More control over retry, monitoring, and reconciliation Do not run a custom Purchase pipeline alongside the native app unless one implementation is disabled for that event or both are proven to use the same event IDs. ### Server-side Purchase request code sketch The following Node.js sketch illustrates the structure. It is not a complete Shopify app and uses placeholder values. ```javascript import crypto from "node:crypto"; function sha256(value) { return crypto .createHash("sha256") .update(value) .digest("hex"); } function normalizeEmail(email) { return email.trim().toLowerCase(); } function normalizePhone(phone) { // Production code should use a proper phone-number library // and require a country context. return phone.replace(/[^\d+]/g, ""); } async function sendPurchaseToMeta({ order, consentGranted, clientIp, clientUserAgent, fbp, fbc }) { if (!consentGranted) { return { skipped: true, reason: "No applicable consent" }; } const eventId = `purchase_${order.id}`; const userData = { client_ip_address: clientIp, client_user_agent: clientUserAgent }; if (fbp) userData.fbp = fbp; if (fbc) userData.fbc = fbc; if (order.email) { userData.em = [sha256(normalizeEmail(order.email))]; } if (order.phone) { userData.ph = [sha256(normalizePhone(order.phone))]; } const payload = { data: [ { event_name: "Purchase", event_time: Math.floor(Date.now() / 1000), event_id: eventId, action_source: "website", event_source_url: `https://cedarandcoil.example/thank-you/${order.id}`, user_data: userData, custom_data: { currency: order.currency, // Example: "USD" value: Number(order.total), order_id: String(order.id), content_type: "product", content_ids: order.lineItems.map(item => String(item.sku)), contents: order.lineItems.map(item => ({ id: String(item.sku), quantity: Number(item.quantity), item_price: Number(item.unitPrice) })), num_items: order.lineItems.reduce( (sum, item) => sum + Number(item.quantity), 0 ) } } ] }; const pixelId = process.env.META_PIXEL_ID; const accessToken = process.env.META_CAPI_ACCESS_TOKEN; const apiVersion = "vXX.X"; // Pin and maintain a supported Graph API version. const response = await fetch( `https://graph.facebook.com/${apiVersion}/${pixelId}/events?access_token=${accessToken}`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(payload) } ); const result = await response.json(); if (!response.ok) { throw new Error(`Meta CAPI error: ${JSON.stringify(result)}`); } return result; } ``` Production implementation should also include: - Secure secret storage - Retry handling with idempotency - Queueing or webhook processing - Shopify order status checks - Protection against sending canceled, test, or duplicate orders - Structured monitoring without logging raw personal data - A reliable method for obtaining the browser’s `fbp`, `fbc`, user agent, IP, consent state, and shared event ID A server webhook that only knows the order ID may be able to send a valid Purchase event, but it may have poorer event matching if browser identifiers and permitted customer information are not carried into the order workflow. --- ## 6. End-to-end validation before scaling spend Run a controlled test before launching ads. ### A. Validate the Shopify catalog - Confirm the Arc Clip Lamp is active in the Meta catalog. - Confirm catalog IDs match the `content_ids` and `contents[].id` values. - Confirm the price and currency are correct. - Confirm product variants do not create inconsistent IDs. ### B. Validate browser events Using Meta Events Manager and browser developer tools: 1. Open the Arc Clip Lamp product page. 2. Confirm one `ViewContent`. 3. Add the product to the cart. 4. Confirm one `AddToCart`. 5. Begin checkout. 6. Confirm one `InitiateCheckout`. 7. Complete a test purchase. 8. Confirm one browser `Purchase`. Check: - Event names - Event IDs - `value` - `currency` - `content_ids` - Page URL - No accidental duplicate firing on refresh or button clicks ### C. Validate CAPI events In Meta Events Manager: - Use **Test Events** where available. - Place a test order and confirm the server-side `Purchase` arrives. - Inspect the event payload and event source. - Confirm the event contains the expected order value, currency, IDs, and permitted user data. - Confirm server requests do not expose the access token in browser code. ### D. Validate deduplication For the same test purchase, verify: - Browser `event_name`: `Purchase` - Server `event_name`: `Purchase` - Browser `event_id`: for example, `purchase_100045` - Server `event_id`: exactly `purchase_100045` Meta should identify the two delivery paths as one deduplicated conversion. If Events Manager reports two separate purchases, investigate: - Different event IDs - Missing event ID on one path - Different event names - Multiple apps or pixels firing - A Purchase event firing on both checkout completion and thank-you-page reload - Duplicate webhook retries without idempotent handling ### E. Validate order integrity Test at least: - Successful purchase - Multiple quantity purchase - Discounted purchase - Failed payment - Canceled order - Thank-you-page refresh - Mobile browser checkout - A customer with and without an email address, subject to consent rules Only successful, valid orders should produce `Purchase`. ### F. Monitor after launch For the first period after launch, compare: - Shopify paid orders - Meta-reported Purchase events - Event counts by source - Reported purchase values - Deduplication diagnostics - Event Match Quality and data-quality warnings Differences between Shopify and Meta are expected because of consent, attribution windows, identity matching, reporting time zones, canceled orders, and platform modeling. Investigate material implementation errors, but do not treat Meta as a financial ledger. --- ## 7. Consent and compliance note Meta tracking must follow applicable privacy laws and Cedar & Coil’s privacy policy. Before sending non-essential Pixel or CAPI data: - Obtain consent where required. - Honor Shopify’s customer privacy settings and regional requirements. - Respect opt-outs and consent withdrawals. - Prevent tracking tags from firing before the appropriate consent decision. - Pass the consent state into any server-side event workflow. - Send only the data needed for the stated advertising and measurement purpose. - Provide a clear privacy notice describing browser and server-side advertising measurement. - Maintain appropriate data-retention, access-control, and deletion procedures. CAPI is not a way to restore data that a visitor declined to share. If consent is absent or withdrawn, suppress the applicable browser and server-side marketing events.
Score · attempt 2 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 browser Pixel plus server CAPI with matching event_id/event_name and explains resilience to cookies/ad blockers/script restrictions.
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 covers ViewContent, AddToCart, InitiateCheckout, and Purchase with value, currency, content_ids, and other parameters for each.
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 in Section 5 includes event_name: 'Purchase', 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 6.C references Meta Events Manager 'Test Events' and Section 6.D explicitly checks that browser and server event_ids/event_names match so Meta deduplicates the two paths.
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).
✓Section 5 describes Purchase as sourced from a Shopify order webhook/server-side workflow and Section 6.D flags 'a Purchase event firing on both checkout completion and thank-you-page reload' as a duplication risk, distinguishing browser vs server sources.
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 guide never gives an attribution-recovery percentage and Section 7 explicitly ties consent/regional rules as constraints on what may be sent, including suppression on opt-out.
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 Meta deduplicates when 'the same event_name' and 'the same event_id' are sent on both Pixel and CAPI, treating them as one conversion rather than two.
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 instructs using a stable order-based ID like `purchase_<shopify_order_id>` and the code sketch derives `eventId = \`purchase_${order.id}\`` deterministically rather than randomly 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: Math.floor(Date.now() / 1000)`, which uses the current send time rather than the order's actual occurrence timestamp, and this isn't corrected elsewhere.
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 sketch normalize email (trim, lowercase) and phone before applying SHA-256 hashing prior to sending 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).
✓Section 5 explicitly states 'For a small DTC store, this is the recommended starting point' for the native Meta sales channel app and lists 9 concrete setup steps.
✗ Attempt 3
Answer · attempt 3 the model's full response$0.006 · 50.2s · 4.5k tok
# Meta Conversion Tracking Implementation Guide for Cedar & Coil ## 1. Recommended architecture Use both: 1. **Browser-side Meta Pixel** 2. **Server-side Meta Conversions API (CAPI)** ### Browser Pixel The Pixel runs in the shopper’s browser and sends events such as: - `ViewContent` - `AddToCart` - `InitiateCheckout` - `Purchase` It can capture browser context, including: - `fbp` browser identifier - `fbc` click identifier when present - page URL - browser and device information ### Server-side Conversions API CAPI sends the same important conversion events from a server or server-managed integration directly to Meta. It is less dependent on: - Browser cookie availability - Ad blockers - JavaScript execution - Intelligent Tracking Prevention and similar browser restrictions - Checkout-page access limitations CAPI should not be treated as a replacement for the Pixel. The Pixel provides useful browser and page context, while CAPI provides a more reliable server-originated signal. Using both also gives Meta more opportunities to match events, provided the events are correctly deduplicated. ### Recommended flow ```text Shopify storefront ├── Meta Pixel: ViewContent, AddToCart, InitiateCheckout, Purchase └── Shopify/Meta server integration: corresponding CAPI events ↓ Meta Events Manager ``` For a small DTC store, the preferred approach is usually Shopify’s official **Facebook & Instagram by Meta** sales channel with the highest available data-sharing setting, rather than building and maintaining a custom event pipeline immediately. --- ## 2. Standard events and required parameters Use Meta’s standard event names exactly. Event names are case-sensitive. ### `ViewContent` Fire when a shopper views the Arc Clip Lamp product page. Recommended parameters: ```json { "content_ids": ["arc-clip-lamp"], "content_type": "product", "content_name": "Arc Clip Lamp", "value": 68.00, "currency": "USD" } ``` Use the Shopify product ID, variant ID, or SKU consistently with the product catalog. The value can be the product price being viewed. ### `AddToCart` Fire after a product is successfully added to the cart, not merely when the add button is clicked. Recommended parameters: ```json { "content_ids": ["arc-clip-lamp"], "contents": [ { "id": "arc-clip-lamp", "quantity": 1, "item_price": 68.00 } ], "content_type": "product", "value": 68.00, "currency": "USD" } ``` For multiple products, `value` should represent the total value of the items added in that event. ### `InitiateCheckout` Fire when the shopper begins checkout, such as when they enter Shopify checkout from the cart. Recommended parameters: ```json { "content_ids": ["arc-clip-lamp"], "contents": [ { "id": "arc-clip-lamp", "quantity": 1, "item_price": 68.00 } ], "content_type": "product", "num_items": 1, "value": 68.00, "currency": "USD" } ``` If shipping, taxes, discounts, or multiple products are included, define the value consistently. The implementation should document whether `value` means item subtotal, subtotal after discount, or another amount. ### `Purchase` Fire only after Shopify confirms a successful order. Do not fire it on: - A cart page - A checkout button click - A payment form submission that has not succeeded - A page reload without protection against duplicate events - A test order that should not enter production reporting Recommended parameters: ```json { "content_ids": ["arc-clip-lamp"], "contents": [ { "id": "arc-clip-lamp", "quantity": 1, "item_price": 68.00 } ], "content_type": "product", "num_items": 1, "value": 68.00, "currency": "USD", "order_id": "shopify-order-12345" } ``` For the Arc Clip Lamp, use the actual Shopify line-item identifier used in the catalog. Do not assume the product title is a valid catalog ID. At minimum, every `Purchase` should include: - `value` - `currency` - `content_ids` - `content_type` - A stable order identifier, such as `order_id` Use the actual order total consistently. If the campaign reports revenue, decide whether that means gross order value, discounted subtotal, or another value and apply the same rule everywhere. --- ## 3. Exactly how deduplication works When both the browser Pixel and CAPI send the same conversion, Meta needs to recognize them as two transmissions of one event. Deduplication requires: 1. The same `event_name` 2. The same `event_id` For example, the browser and server must both send: ```text event_name: Purchase event_id: purchase-shopify-order-12345 ``` ### Browser-side example ```javascript const eventId = "purchase-shopify-order-12345"; fbq( "track", "Purchase", { value: 68.00, currency: "USD", content_ids: ["arc-clip-lamp"], content_type: "product", order_id: "shopify-order-12345" }, { eventID: eventId } ); ``` ### Server-side equivalent The CAPI request must contain: ```json { "event_name": "Purchase", "event_id": "purchase-shopify-order-12345" } ``` The `event_id` is not the same as `event_name`, the order value, or the order ID by itself. It is the shared identifier that links the browser and server copies. ### Practical implementation rules - Generate one event ID for the conversion. - Make it available to both the browser event and the server event. - Persist it long enough for retries. - Send the same event ID if a server request is retried. - Do not generate a new event ID for every retry. - Do not send one browser `Purchase` and multiple server `Purchase` events with different IDs for the same order. - Use the same event name and event ID only for the same logical event. For purchases, an order-based ID is practical, for example: ```text purchase-{shopify_order_id} ``` For non-purchase events, use a unique ID for each action, such as: ```text add-to-cart-{cart_token}-{timestamp_or_action_nonce} ``` A Shopify-native integration may manage the event ID and deduplication internally. Do not add a second custom Pixel or CAPI implementation unless it has been verified that the native integration is not already sending those events. --- ## 4. Preparing customer information for server-side events CAPI uses `user_data` to help Meta match an event to an ad interaction. Send only information that is permitted by the applicable consent and privacy rules. ### Normalize before hashing For fields that Meta expects hashed, normalize them first and then apply SHA-256. Common normalization examples: - **Email:** trim whitespace and lowercase - **Phone:** convert to a consistent international format, preferably E.164 - **Name:** trim, lowercase, and apply the format required by Meta - **Postal code and country:** normalize consistently - **External ID:** use a stable store customer ID where permitted Example: ```text " Shopper@Example.COM " → "shopper@example.com" ``` Then hash the normalized value: ```text sha256(normalized_value) ``` ### Fields commonly sent in `user_data` Depending on availability and consent: - `em`: normalized, SHA-256 hashed email - `ph`: normalized, SHA-256 hashed phone - `fn`, `ln`: normalized, SHA-256 hashed first and last name - `ct`, `st`, `zp`, `country`: normalized and hashed as required - `external_id`: stable customer identifier, hashed if required by the implementation - `fbp`: browser identifier, generally sent as received and not hashed - `fbc`: click identifier, generally sent as received and not hashed - `client_ip_address`: server-observed client IP where legally appropriate - `client_user_agent`: browser user-agent string Do not hash fields merely because they are being sent server-side. In particular, `fbp`, `fbc`, IP address, and user-agent have different handling from email and phone. ### Important safeguards - Do not send raw email addresses or phone numbers when Meta expects hashed values. - Do not invent customer information. - Do not use sensitive data that is unnecessary for conversion matching. - Do not pass payment card numbers, CVV values, or full payment credentials. - Strip or avoid URL query parameters that contain personal information. - Respect Shopify’s customer privacy and consent state before collecting or forwarding identifiers. CAPI matching is probabilistic and depends on the quality, availability, and lawful use of the identifiers. It should not be described as guaranteeing a particular match rate or recovery percentage. --- ## 5. Concrete Shopify setup path ### Option A: Shopify’s native Meta sales channel For Cedar & Coil, this is the recommended starting point. #### Setup path 1. In Shopify admin, open **Sales channels**. 2. Add or open **Facebook & Instagram by Meta**. 3. Connect the appropriate: - Meta Business Portfolio - Facebook Page, if required - Instagram account, if required - Meta ad account - Meta Pixel/dataset - Product catalog 4. In the channel’s data-sharing settings, select the highest available setting that is permitted by Cedar & Coil’s consent and privacy configuration. 5. Confirm that the Arc Clip Lamp is approved and present in the Meta catalog. 6. Confirm that the product identifier in Shopify matches the identifier used in Meta catalog items. 7. Configure Shopify customer privacy settings and regional consent behavior. 8. Verify the store domain in Meta Business settings. 9. Check Meta Events Manager for the connected dataset and incoming browser/server events. 10. Avoid installing a separate manually coded Pixel if the sales channel already inserts one. The native channel generally handles much of the Shopify-to-Meta plumbing, including browser and server event transmission, catalog connection, and purchase data. Exact labels and available settings can change as Shopify and Meta update their interfaces. #### Advantages - Fastest implementation for a small store - Less custom infrastructure to maintain - Better alignment with Shopify checkout limitations - Lower risk of duplicate purchase events from separate systems - Easier catalog and product-ID synchronization #### Limitations - Less control over event payloads and custom business logic - Some checkout and customer fields are controlled by Shopify - Debugging can require checking both Shopify and Meta interfaces - The implementation may not expose every field a larger organization wants ### Option B: Custom implementation A custom implementation may be appropriate when Cedar & Coil needs: - Custom order-processing logic - A data warehouse as the event source - Multiple storefronts or checkout systems - Specialized consent orchestration - Custom retry, monitoring, or event governance - Full control over payloads and event IDs A custom build normally requires: - Browser Pixel implementation - A server endpoint or backend worker - Shopify webhooks or order-event processing - Secure storage of the Meta access token - Event-ID persistence and retry handling - Consent-state propagation - Monitoring for failures and duplicates - Catalog-ID mapping Shopify checkout and thank-you-page restrictions can make a custom purchase implementation more involved than a storefront-only script. For that reason, a small DTC store should start with the native Meta sales channel unless there is a specific requirement it cannot satisfy. ### Illustrative server-side Purchase request This is a conceptual Node.js example. Use the current Graph API version and endpoint documented in Meta’s Conversions API documentation. ```javascript import crypto from "node:crypto"; const META_PIXEL_ID = process.env.META_PIXEL_ID; const META_ACCESS_TOKEN = process.env.META_ACCESS_TOKEN; const META_API_VERSION = process.env.META_API_VERSION; // e.g. current supported version function sha256(value) { return crypto .createHash("sha256") .update(value) .digest("hex"); } function normalizeEmail(email) { return email.trim().toLowerCase(); } function normalizePhone(phone) { // Production code should use a proper phone-number library // and convert to the required international format. return phone.replace(/[^\d+]/g, ""); } export async function sendPurchaseToMeta({ order, eventId, eventSourceUrl, consentAllowsAdsMeasurement }) { if (!consentAllowsAdsMeasurement) { return { skipped: true, reason: "No permitted measurement consent" }; } const userData = { em: [sha256(normalizeEmail(order.email))], external_id: [sha256(String(order.customerId))] }; if (order.phone) { userData.ph = [sha256(normalizePhone(order.phone))]; } // These values are not hashed. Include them only when lawfully available. if (order.fbp) userData.fbp = order.fbp; if (order.fbc) userData.fbc = order.fbc; if (order.clientIp) userData.client_ip_address = order.clientIp; if (order.userAgent) userData.client_user_agent = order.userAgent; const payload = { data: [ { event_name: "Purchase", event_time: Math.floor(Date.now() / 1000), event_id: eventId, action_source: "website", event_source_url: eventSourceUrl, user_data: userData, custom_data: { value: Number(order.totalPrice), currency: order.currency || "USD", content_type: "product", content_ids: order.lineItems.map(item => String(item.catalogId)), contents: order.lineItems.map(item => ({ id: String(item.catalogId), quantity: Number(item.quantity), item_price: Number(item.price) })), num_items: order.lineItems.reduce( (sum, item) => sum + Number(item.quantity), 0 ), order_id: String(order.id) } } ] }; const url = `https://graph.facebook.com/${META_API_VERSION}/` + `${META_PIXEL_ID}/events?access_token=${encodeURIComponent(META_ACCESS_TOKEN)}`; const response = await fetch(url, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(payload) }); const result = await response.json(); if (!response.ok) { throw new Error(`Meta CAPI error: ${JSON.stringify(result)}`); } return result; } ``` Production considerations: - Keep the access token only on the server. - Use a Shopify order webhook or another authoritative order source. - Mark an order/event as sent and preserve the original `event_id`. - Implement safe retries with the same event ID. - Do not send canceled, fraudulent, or invalid orders as completed purchases. - Ensure the browser-side purchase event uses the identical `event_id`. - Validate catalog IDs before sending. --- ## 6. End-to-end validation before scaling spend Run a complete test using the Arc Clip Lamp before launching ads. ### A. Validate the Shopify and Meta connection Confirm: - The correct Meta Business Portfolio is connected. - The correct ad account and dataset are selected. - The Arc Clip Lamp appears in the Meta catalog. - Shopify product IDs or SKUs map to Meta catalog IDs. - The verified domain is the actual production storefront domain. ### B. Validate browser events Use: - Meta Events Manager - Meta Pixel Helper or browser developer tools - Browser network inspection Test each event: 1. Open the Arc Clip Lamp product page and verify `ViewContent`. 2. Add the product to cart and verify one `AddToCart`. 3. Begin checkout and verify one `InitiateCheckout`. 4. Complete a controlled test order and verify one `Purchase`. Check: - Event name - Event timestamp - Event source URL - `value` - `currency` - `content_ids` - `content_type` - Quantity and contents - Presence of browser identifiers where permitted ### C. Validate CAPI events In Meta Events Manager’s test tools, confirm that the server event arrives and inspect: - `event_name` - `event_id` - `event_time` - `action_source` - `user_data` - `custom_data` - event processing status - diagnostics or warnings Use Meta’s test event code only during testing and remove it from production traffic. ### D. Validate deduplication For the test purchase: 1. Record the browser Pixel event ID. 2. Record the CAPI event ID. 3. Confirm they are identical. 4. Confirm the event names are both `Purchase`. 5. Confirm Meta identifies the browser and server transmissions as one deduplicated event rather than two purchases. A browser purchase plus a server purchase with different IDs is a common cause of inflated conversion and revenue reporting. ### E. Test operational edge cases Test at least: - Page reload on the order confirmation page - A customer returning to the confirmation URL - Payment failure - Order cancellation - Refund - Multiple quantities - Discount code - Shipping and tax - Mobile Safari or another privacy-restrictive browser - Ad-blocking or JavaScript-disabled behavior, where applicable - A shopper who declines measurement consent The final test should compare Shopify’s order record with Meta’s received event, without assuming the two systems will have identical attribution totals. --- ## 7. Consent and compliance note Cedar & Coil should configure tracking according to the laws and platform requirements applicable to each visitor’s location. Key practices: - Use Shopify’s customer privacy and consent tools. - Obtain the required consent before placing non-essential marketing cookies or sending optional advertising identifiers. - Do not send browser or server events when the applicable consent state prohibits that measurement. - Propagate consent status from the storefront to any server-side event processor. - Provide a clear privacy notice explaining the use of Meta Pixel and Conversions API. - Honor opt-out, deletion, and access requests. - Limit CAPI data to necessary, permitted fields. - Hash customer identifiers according to Meta’s requirements before sending them. - Do not send payment credentials or unrelated sensitive information. - Review regional requirements such as GDPR/UK GDPR, ePrivacy rules, and applicable U.S. state privacy laws with qualified legal counsel. CAPI is still processing personal information even though it is server-side. Moving an event from the browser to a server does not eliminate consent, disclosure, security, or data-minimization obligations.
Score · attempt 3 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.
✓The guide explains Pixel for browser context and CAPI for server-side reliability against ITP/ad blockers, stating 'CAPI should not be treated as a replacement for the Pixel... Using both also gives Meta more opportunities to match events, provided the events are correctly deduplicated.'
events_mapped
All four standard events (ViewContent, AddToCart, InitiateCheckout, Purchase) are covered with key parameters, including value, currency, and content_ids on Purchase.
✓All four events (ViewContent, AddToCart, InitiateCheckout, Purchase) are given with parameter blocks, and Purchase explicitly includes 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 sendPurchaseToMeta function includes event_name, event_time, event_id, 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 instructs using Meta Events Manager's test tools and Section D explicitly checks 'Confirm Meta identifies the browser and server transmissions as one deduplicated event rather than two purchases.'
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 Purchase should fire 'only after Shopify confirms a successful order' and recommends using 'a Shopify order webhook or another authoritative order source' 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 guide states matching 'should not be described as guaranteeing a particular match rate or recovery percentage' and dedicates Section 7 to consent/regional 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.
✓It explicitly requires 'The same event_name' and 'The same event_id' shared between the fbq call and the CAPI payload for Meta to deduplicate.
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 'Send the same event ID if a server request is retried' and 'Do not generate a new event ID for every retry,' using an order-based ID pattern like purchase-{shopify_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 sketch sets `event_time: Math.floor(Date.now() / 1000)`, using the current send time rather than the order's creation/occurrence timestamp, and no text elsewhere corrects this for 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 shows normalizeEmail (trim + lowercase) applied before sha256 hashing, and explicitly instructs normalizing before hashing for email/phone/name 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 ('For Cedar & Coil, this is the recommended starting point') with a numbered 10-step setup path for the native Meta sales channel.

GPT-5.6 Terra medium 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.076 · 68.3s · 6.2k tok
# Cedar & Coil Meta Conversion Tracking Implementation Guide This guide covers a reliable Shopify-to-Meta conversion setup for the Arc Clip Lamp, using both the browser Meta Pixel and Meta Conversions API (CAPI). The goal is to measure the customer journey from product view through purchase while remaining resilient to browser privacy restrictions and compliant with consent requirements. --- ## 1. Recommended Architecture: Meta Pixel + Conversions API ### Recommended setup Use both: 1. **Meta Pixel in the browser** - Sends events from the shopper’s browser to Meta. - Captures browser identifiers such as `_fbp` and, when available, `_fbc`. - Supports Meta’s browser-side campaign measurement and retargeting. 2. **Meta Conversions API (CAPI) from the server** - Sends the same important conversion events from Cedar & Coil’s server or Shopify integration to Meta. - Is less dependent on browser cookies, ad blockers, page-load failures, or browser privacy controls. - Can send consented first-party customer data in hashed form to help Meta match events. 3. **Event deduplication** - Ensures that when both the Pixel and CAPI report the same conversion, Meta counts it once rather than twice. ### Why both are needed Browser-only tracking is vulnerable to: - Safari, Firefox, and other browser privacy controls. - Cookie expiration or rejection. - Ad blockers and script blocking. - The customer closing a tab before client-side confirmation tracking completes. - Network failures during browser event delivery. Server-only tracking is also insufficient on its own because it can lose useful browser context, including click identifiers and browser identifiers used for matching. It may also be harder to support dynamic remarketing and on-site event behavior without a browser Pixel. The combined model is: ```text Shopper browser ├─ Meta Pixel ───────────────► Meta │ ViewContent / AddToCart / InitiateCheckout / Purchase │ Shopify store / server └─ Conversions API ──────────► Meta Same conversion events where appropriate Same event_id for deduplication ``` For a small Shopify DTC store, use the native Shopify Meta integration unless there is a specific, documented need for custom event logic or a separate server-side event platform. --- ## 2. Standard Events and Required Parameters Track the following Meta standard events. Use the same product/catalog IDs across Shopify, Meta Commerce Manager, Pixel events, and CAPI events. For Shopify catalogs, this is commonly a Shopify variant identifier formatted by the integration, such as: ```text shopify_US_1234567890_9876543210 ``` Do not invent the ID format. Inspect the catalog feed or the native integration’s emitted events and use the exact catalog item ID Meta receives. ### Event summary | Funnel stage | Meta standard event | When to send | |---|---|---| | Product page view | `ViewContent` | When a shopper views the Arc Clip Lamp product page | | Cart action | `AddToCart` | When the shopper adds the lamp to cart | | Checkout start | `InitiateCheckout` | When checkout begins | | Completed order | `Purchase` | Once an order is successfully paid or confirmed, depending on the configured purchase definition | ### `ViewContent` Send on the Arc Clip Lamp product detail page. Recommended parameters: ```json { "content_ids": ["CATALOG_VARIANT_ID"], "content_type": "product", "content_name": "Arc Clip Lamp", "value": 68.00, "currency": "USD", "contents": [ { "id": "CATALOG_VARIANT_ID", "quantity": 1, "item_price": 68.00 } ] } ``` Notes: - `content_ids` must match the Meta catalog’s item ID. - `content_type` should normally be `"product"` for a product-level event. - `value` should reflect the product price shown for the selected variant or configuration. - Use ISO currency code `"USD"`. ### `AddToCart` Send when the customer actively adds the Arc Clip Lamp to cart. Recommended parameters: ```json { "content_ids": ["CATALOG_VARIANT_ID"], "content_type": "product", "value": 68.00, "currency": "USD", "contents": [ { "id": "CATALOG_VARIANT_ID", "quantity": 1, "item_price": 68.00 } ] } ``` If quantity can exceed one, set `quantity` and `value` accordingly. Example for two lamps: ```json { "value": 136.00, "currency": "USD", "contents": [ { "id": "CATALOG_VARIANT_ID", "quantity": 2, "item_price": 68.00 } ] } ``` ### `InitiateCheckout` Send when the shopper starts checkout, not simply when they view the cart. Recommended parameters: ```json { "content_ids": ["CATALOG_VARIANT_ID"], "content_type": "product", "value": 68.00, "currency": "USD", "num_items": 1, "contents": [ { "id": "CATALOG_VARIANT_ID", "quantity": 1, "item_price": 68.00 } ] } ``` For a multi-item cart: - Send all relevant `contents`. - Send all catalog IDs in `content_ids`. - Use the current cart subtotal or the value definition chosen for reporting. - Keep the same value convention across Pixel and CAPI. ### `Purchase` Send once per completed order. Recommended parameters: ```json { "content_ids": [ "CATALOG_VARIANT_ID" ], "content_type": "product", "value": 68.00, "currency": "USD", "num_items": 1, "order_id": "1001", "contents": [ { "id": "CATALOG_VARIANT_ID", "quantity": 1, "item_price": 68.00 } ] } ``` Key requirements: - `value`: The order value being reported to Meta. - `currency`: `"USD"` for Cedar & Coil’s current store currency. - `content_ids`: Required for catalog matching and product-level reporting. - `contents`: Send each purchased line item with ID, quantity, and item price. - `order_id`: Recommended for internal reconciliation, troubleshooting, and idempotency. Do not use it as the Meta event ID unless it is opaque or otherwise safe for that use. ### Purchase value convention Choose a documented convention and use it consistently. A common approach is: - Send the **order total** as `value`, including discounts and, if intended, tax and shipping. - Send individual product prices and quantities in `contents`. Alternatively, send product subtotal excluding shipping and tax, if that aligns with internal reporting. The important rule is consistency between: - Shopify reporting definitions, - browser Pixel events, - CAPI events, and - ad reporting expectations. Do not represent the Arc Clip Lamp’s list price as $68 on a purchase event if the customer actually paid a discounted amount. --- ## 3. How Pixel/CAPI Deduplication Works ### The rule Meta deduplicates browser and server events when the two events have: 1. The same `event_name`, and 2. The same `event_id`. For example: ```text Browser Pixel: event_name = Purchase event_id = 9f554ad4-9a7f-4ec0-9a76-5adf5c684d40 Server CAPI: event_name = Purchase event_id = 9f554ad4-9a7f-4ec0-9a76-5adf5c684d40 ``` Meta should treat these as one Purchase rather than two. ### Browser Pixel example ```javascript fbq( 'track', 'Purchase', { value: 68.00, currency: 'USD', content_ids: ['CATALOG_VARIANT_ID'], content_type: 'product' }, { eventID: '9f554ad4-9a7f-4ec0-9a76-5adf5c684d40' } ); ``` The Pixel parameter is named `eventID` with a capitalized `ID`. ### Server CAPI example ```json { "event_name": "Purchase", "event_time": 1735689600, "event_id": "9f554ad4-9a7f-4ec0-9a76-5adf5c684d40", "action_source": "website" } ``` The CAPI field is named `event_id` with an underscore. ### Implementation pattern For a custom implementation: 1. Generate a unique event ID in the browser when the event occurs. 2. Send the event through the Pixel with that ID. 3. Persist that event ID so the server can access it. 4. Send the matching server event using the same ID. For Purchase, the identifier must survive the transition from storefront to checkout and then be available to the purchase-processing system. Common methods include: - A cart attribute. - A checkout attribute or order note attribute, where Shopify permissions and checkout configuration permit it. - A first-party event store keyed to a cart token, checkout token, or internal session identifier. - A server-side event platform that maintains the mapping. ### Important deduplication rules - Use a **new event ID for each separate event occurrence**. - Use the **same event ID only for the browser/server copies of that one occurrence**. - Retry failed CAPI delivery using the same event ID, not a newly generated ID. - Do not use the same generic ID for every Purchase. - Do not run a native Shopify Purchase integration and a separate custom Purchase implementation unless you have verified that events are deduplicated correctly. - Deduplication is most reliable when browser and server events are sent close together. Send server events promptly after the relevant conversion is known. ### Native Shopify integration note When using Shopify’s Facebook & Instagram by Meta sales channel with customer data sharing enabled, Shopify and Meta manage much of the Pixel/CAPI event pairing. Do not add duplicate custom `Purchase` events on top of the native integration without a clear reason and a tested deduplication plan. --- ## 4. Preparing Customer Information for Server-Side Events CAPI can use consented first-party customer information in `user_data` to improve event matching. Customer data must be normalized and hashed correctly before it is sent, unless Meta explicitly identifies a field as un-hashed. ### Fields commonly used Where collected and permitted, send: - `em`: Email address. - `ph`: Phone number. - `fn`: First name. - `ln`: Last name. - `ct`: City. - `st`: State or region. - `zp`: ZIP or postal code. - `country`: Country code. - `external_id`: Cedar & Coil’s stable internal customer ID, if available and appropriate. - `fbp`: The browser’s `_fbp` cookie value. - `fbc`: The Facebook click ID cookie value, if present after a `fbclid` click. - `client_ip_address`: Customer IP address observed by the server. - `client_user_agent`: Customer browser user agent. ### Hashing requirements Personally identifiable fields must generally be: 1. Normalized. 2. SHA-256 hashed. 3. Sent as lowercase hexadecimal hashes. Examples: | Field | Normalize before SHA-256 hashing | |---|---| | Email | Trim whitespace and lowercase | | Phone | Remove punctuation/spaces; include country code where possible | | First/last name | Trim and lowercase | | City/state | Trim and lowercase | | Postal code | Trim, lowercase, retain meaningful characters | | Country | Use lowercased ISO two-letter code, such as `us` | Example: ```text Original email: " Maya.Renter@Example.com " Normalized: "maya.renter@example.com" SHA-256: <sha256 hash of normalized value> ``` ### Do not hash these fields Do not SHA-256 hash: - `fbp` - `fbc` - `client_ip_address` - `client_user_agent` These are passed in their required raw formats, subject to consent and applicable law. ### Example CAPI `user_data` ```json { "em": ["SHA256_NORMALIZED_EMAIL"], "ph": ["SHA256_NORMALIZED_PHONE"], "fn": ["SHA256_NORMALIZED_FIRST_NAME"], "ln": ["SHA256_NORMALIZED_LAST_NAME"], "ct": ["SHA256_NORMALIZED_CITY"], "st": ["SHA256_NORMALIZED_STATE"], "zp": ["SHA256_NORMALIZED_POSTAL_CODE"], "country": ["SHA256_NORMALIZED_COUNTRY"], "external_id": ["SHA256_INTERNAL_CUSTOMER_ID"], "fbp": "fb.1.1735689000000.123456789", "fbc": "fb.1.1735689000000.AbCdEfGhIjKlMnOp", "client_ip_address": "203.0.113.10", "client_user_agent": "Mozilla/5.0 ..." } ``` ### Data-minimization rules - Send only fields Cedar & Coil has actually collected. - Do not invent customer information. - Do not use sensitive categories, health information, financial information, or any data prohibited by Meta policy. - Do not send raw email addresses or raw phone numbers in CAPI user data. - Do not use CAPI as a way to override a user’s tracking refusal. --- ## 5. Concrete Shopify Setup Path ## Option A: Native Shopify Meta Sales Channel App ### What it is Use Shopify’s official **Facebook & Instagram by Meta** sales channel. The exact labels may change over time, but the app is available through Shopify’s sales channel/app flow. It typically handles: - Meta Pixel installation. - Connection to a Meta dataset/pixel. - Product catalog synchronization. - Browser conversion events. - Conversions API connection when customer data sharing is enabled. - Product IDs aligned with the synced Meta catalog. - Basic event deduplication between browser and server events. ### Setup steps 1. In Shopify Admin, install or open **Facebook & Instagram by Meta**. 2. Connect Cedar & Coil’s: - Meta Business Portfolio. - Facebook Page, if applicable. - Meta ad account. - Meta dataset / Pixel. 3. Confirm the Meta catalog is connected and Shopify products are syncing. 4. Verify that the Arc Clip Lamp appears in the catalog. 5. Configure customer data sharing in the Meta sales channel. - Select the highest level that is appropriate for Cedar & Coil’s consent model and applicable legal requirements. - This generally enables server-side sharing in addition to browser Pixel tracking. 6. Confirm the Pixel/dataset is selected as the event destination. 7. Avoid adding a second standard Meta Pixel through theme code, Google Tag Manager, or another app unless there is a deliberate multi-pixel architecture. 8. Avoid installing a separate Purchase CAPI app on top of the native app without confirming ownership of event generation and deduplication. ### Advantages - Lowest implementation and maintenance burden. - Shopify product catalog IDs are generally handled automatically. - Better fit for standard Shopify checkout behavior. - Managed Pixel/CAPI integration and event deduplication. - Faster to validate before launching ads. ### Limitations - Less control over payload structure and timing. - Less flexibility for unusual custom funnel events. - More limited ability to maintain a custom event store or add non-Shopify backend conversions. - Setup labels and behavior can change as Shopify and Meta update the integration. --- ## Option B: Custom Pixel + Custom CAPI Implementation ### What it is A custom solution might use: - Theme code or Shopify Customer Events / Custom Pixel for browser events. - A server-side application, serverless function, or tracking platform for CAPI. - Shopify webhooks such as paid-order events for reliable Purchase confirmation. - A first-party store for linking browser event IDs to orders/checkouts. ### When it is appropriate Use a custom implementation when Cedar & Coil has a real requirement such as: - A nonstandard checkout or headless storefront. - A separate backend payment or fulfillment system. - Complex subscription, lead, or offline conversion flows. - A need for custom data governance, event routing, or warehouse integration. - A technical team capable of monitoring, maintaining, and testing it. ### Risks A custom setup can easily cause: - Duplicate purchases. - Missing purchase events. - Catalog ID mismatches. - Improper hashing. - Missing consent controls. - Server events with weak match quality because `_fbp`, `_fbc`, IP, or user agent were not captured correctly. - Purchase timing mismatches between payment authorization, payment capture, and order confirmation. ### Recommendation for Cedar & Coil For a small DTC Shopify store selling the Arc Clip Lamp, start with the **native Facebook & Instagram by Meta Shopify sales channel**. It is the most practical path because: - The store uses standard Shopify commerce flows. - The catalog is simple. - The product is a single $68 lamp rather than a complex multi-system purchase flow. - Shopify’s managed implementation reduces the likelihood of catalog-ID errors and duplicate event logic. Add custom CAPI only if the native setup fails a documented measurement requirement that cannot be solved within the integration. --- ### Custom server-side Purchase event sketch The following is illustrative pseudocode for a custom implementation. It should not be deployed in parallel with Shopify’s native Purchase CAPI unless duplicate ownership and deduplication have been designed and tested. A common server trigger is a Shopify order-paid webhook. Verify the Shopify webhook signature before processing it. ```javascript import crypto from "crypto"; const META_PIXEL_ID = process.env.META_PIXEL_ID; const META_CAPI_TOKEN = process.env.META_CAPI_TOKEN; function sha256(value) { return crypto .createHash("sha256") .update(value.trim().toLowerCase()) .digest("hex"); } async function sendMetaPurchase(order, attributionContext) { // Keep a stable event ID for retries. // Ideally this is the browser-generated Purchase event ID mapped to the order. // If no browser event exists, generate one once and persist it with the order. const eventId = attributionContext.purchaseEventId || `shopify-order-${order.id}`; const contents = order.line_items.map((item) => ({ // Must match the ID in the connected Meta catalog. id: item.meta_catalog_variant_id, quantity: item.quantity, item_price: Number(item.price) })); const contentIds = contents.map((item) => item.id); const userData = {}; if (order.email) { userData.em = [sha256(order.email)]; } if (order.phone) { const normalizedPhone = order.phone.replace(/[^\d+]/g, ""); userData.ph = [sha256(normalizedPhone)]; } // Capture these earlier in the browser/session when available. // Do not hash fbp or fbc. if (attributionContext.fbp) userData.fbp = attributionContext.fbp; if (attributionContext.fbc) userData.fbc = attributionContext.fbc; if (attributionContext.ip) { userData.client_ip_address = attributionContext.ip; } if (attributionContext.userAgent) { userData.client_user_agent = attributionContext.userAgent; } const payload = { data: [ { event_name: "Purchase", event_time: Math.floor(new Date(order.processed_at).getTime() / 1000), event_id: eventId, action_source: "website", event_source_url: attributionContext.eventSourceUrl, user_data: userData, custom_data: { currency: order.currency || "USD", value: Number(order.total_price), order_id: String(order.order_number), content_type: "product", content_ids: contentIds, num_items: order.line_items.reduce( (total, item) => total + item.quantity, 0 ), contents } } ] }; const response = await fetch( `https://graph.facebook.com/vXX.X/${META_PIXEL_ID}/events?access_token=${META_CAPI_TOKEN}`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(payload) } ); if (!response.ok) { throw new Error(`Meta CAPI request failed: ${await response.text()}`); } return response.json(); } ``` Implementation requirements omitted from the sketch but required in production: - Verify Shopify webhook signatures. - Store CAPI credentials in a secrets manager, not source code. - Persist sent event IDs and delivery results. - Retry safely with the same `event_id`. - Add idempotency handling for duplicate Shopify webhooks. - Capture `_fbp`, `_fbc`, IP, user agent, and browser event ID only with appropriate consent. - Use the exact Meta catalog variant IDs. - Send test events using Meta’s test event code only in non-production validation. - Log failures without logging raw customer personal data. --- ## 6. Validate End to End Before Scaling Spend Do not scale Meta spend until the full path is tested: browser event, server event, catalog match, deduplication, and order-value accuracy. ## A. Pre-launch configuration checklist Confirm: - The correct Meta dataset / Pixel is connected to the ad account. - The Arc Clip Lamp is present and approved in the Meta catalog. - The storefront sends only one browser Pixel implementation. - Purchase is not being sent by multiple apps without planned deduplication. - Customer data sharing and consent settings are configured. - Meta CAPI access token, if custom, is valid and stored securely. - Currency is consistently sent as `USD`. - Product IDs in events match catalog IDs exactly. ## B. Test the browser journey Use a private/incognito browser session where appropriate, then test: 1. Open the Arc Clip Lamp product page. 2. Confirm `ViewContent`. 3. Add the lamp to cart. 4. Confirm `AddToCart`. 5. Begin checkout. 6. Confirm `InitiateCheckout`. 7. Complete a test order using Shopify’s test payment method or a controlled test order process. 8. Confirm one `Purchase`. Tools: - **Meta Events Manager → Test Events** - **Meta Pixel Helper** browser extension - Browser developer tools: - Network tab - Console - Cookies/storage inspection, where permitted Check that: - The Pixel events arrive. - Parameters are populated correctly. - `value` and `currency` are accurate. - `content_ids` match the catalog. - Purchase contains all purchased line items. ## C. Test CAPI delivery In Meta Events Manager: 1. Open the dataset. 2. Go to **Test Events**. 3. If using custom CAPI, use a Meta test event code during testing. 4. Send a controlled test event. 5. Confirm the event appears as a server event. 6. Review any warnings or diagnostics. For a native Shopify setup, use a controlled test order and verify that both browser and server activity is visible in Events Manager where Meta exposes that detail. ## D. Confirm deduplication For a completed test order, verify that Meta identifies the browser/server Purchase copies as deduplicated or does not show two counted Purchase events. Investigate if you see: - Two Purchase events for one Shopify order. - One browser event and one server event with different IDs. - Server Purchase events without corresponding browser events when the browser event should have fired. - Inconsistent purchase values. - Duplicate Purchase events after webhook retries. For custom implementations, log these values for each test order: ```text Shopify order number Shopify order ID Browser Purchase event ID Server Purchase event ID Pixel event timestamp CAPI event timestamp Order value sent Currency sent Catalog item IDs sent CAPI response / event ID ``` Do not log raw email addresses, phone numbers, access tokens, or other unnecessary customer data. ## E. Check Event Match Quality and diagnostics In Meta Events Manager, review: - Event Match Quality indicators. - Pixel and CAPI diagnostics. - Warnings about missing `content_ids`, currency, value, or user data. - Catalog matching behavior. - Duplicate event warnings. Event Match Quality can help identify implementation gaps, but it is not a promise of reporting outcomes. Improve data quality where lawful and consented; do not add data merely to optimize a score. ## F. Reconcile with Shopify After several real or controlled orders: - Compare Shopify completed orders with Meta Purchase event count. - Compare reported purchase values using the same value definition. - Investigate material discrepancies before increasing budget. - Expect some normal differences in timing, attribution windows, consent status, and reporting methodology; focus first on clear technical errors such as duplicates, missing events, or incorrect value/currency. --- ## 7. Consent and Compliance CAPI is not a mechanism for bypassing privacy choices. Server-side tracking still requires a lawful basis and a consent approach appropriate to Cedar & Coil’s customers and applicable regulations. ### Practical requirements - Use a consent-management approach appropriate for the markets where Cedar & Coil sells. - Clearly disclose Meta advertising and measurement data sharing in the privacy policy. - Respect opt-outs, consent refusals, and applicable “do not sell/share” or similar rights. - Do not send browser or server marketing data before consent where prior consent is required. - Ensure the consent tool controls both: - browser Pixel firing, and - server-side CAPI event enrichment or sending. - Maintain records of consent where required. - Enter into and review necessary platform terms, including Meta’s business tools terms and any applicable data-processing terms. - Limit data collection to what is necessary for measurement and advertising purposes. - Set appropriate data-retention, access-control, and incident-response practices. ### Special caution for customer data Only send customer information that: 1. Cedar & Coil collected directly, 2. Cedar & Coil is permitted to use for this purpose, and 3. Meta permits under its business tools policies. Hashing protects data in transit and supports matching, but it does not remove Cedar & Coil’s privacy, disclosure, consent, or data-governance responsibilities. --- ## Recommended Launch Decision For Cedar & Coil’s initial Arc Clip Lamp campaign: 1. Install and configure the native **Facebook & Instagram by Meta** Shopify sales channel. 2. Connect the correct dataset/pixel, catalog, and ad account. 3. Enable the appropriate consented customer data sharing configuration. 4. Verify `ViewContent`, `AddToCart`, `InitiateCheckout`, and `Purchase`. 5. Confirm catalog IDs, purchase values, and deduplication with test orders. 6. Only consider custom CAPI if a validated tracking requirement remains unmet by the native integration.
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 explicitly recommends both Pixel and CAPI with deduplication and lists browser privacy limitations (Safari/Firefox controls, ad blockers, tab closures) as the reason 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 covers ViewContent, AddToCart, InitiateCheckout, and Purchase, each with value, currency, content_ids, and other parameters.
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 'Custom server-side Purchase event sketch' JS function builds a payload with event_name, event_time, event_id, action_source, 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.C references Meta Events Manager → Test Events and 6.D explicitly instructs verifying that browser/server Purchase copies are deduplicated or not double-counted.
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 Purchase event's source of truth is defined as a Shopify order-paid webhook ('A common server trigger is a Shopify order-paid webhook') rather than solely a thank-you page, while browser events are tied to Pixel firing on page/cart/checkout actions.
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 guide never promises attribution-recovery percentages and Section 7 frames consent/regional rules as hard constraints on what data may be sent ('Do not send browser or server marketing data before consent where prior consent is required').
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 Meta deduplicates when 'the same event_name' and 'the same event_id' are used on both Pixel and CAPI events, with matching examples shown.
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 code sketch derives eventId from a persisted browser ID or `shopify-order-${order.id}` and the text instructs 'Retry failed CAPI delivery using the same event ID, not a newly generated 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.
✓event_time is computed as `Math.floor(new Date(order.processed_at).getTime() / 1000)`, using the order's processed timestamp rather than the current send time.
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 sha256 helper trims and lowercases the value before hashing, and is applied to email and phone fields 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 ('start with the native Facebook & Instagram by Meta Shopify sales channel') with concrete numbered setup steps for a small DTC store.
✓ Attempt 2
Answer · attempt 2 the model's full response$0.083 · 78.4s · 6.9k tok
# Cedar & Coil Meta Conversion Tracking Implementation Guide ## 1. Recommended architecture: Meta Pixel + Conversions API Use a **hybrid implementation**: 1. **Browser-side Meta Pixel** on the Shopify storefront 2. **Server-side Meta Conversions API (CAPI)** sending the same key conversion events from Shopify/backend systems 3. **Event deduplication** so Meta recognizes browser and server reports of the same action as one conversion ### Why both are needed The browser Pixel remains important because it can capture: - On-site behavior such as product views and add-to-cart actions - Meta browser identifiers, including `_fbp` and `_fbc` - Referrer and landing-page context - Fast, client-side event delivery However, browser events can be lost or degraded because of: - Safari and other browser privacy controls - Ad blockers and tracking protection - Cookie restrictions - User navigation away from confirmation pages - Script-loading failures CAPI sends events from Cedar & Coil’s server or Shopify-connected integration directly to Meta. It is less dependent on the shopper’s browser successfully loading and transmitting a Pixel event. CAPI is **not** a replacement for consent requirements or a way to bypass browser privacy choices. It is a complementary event-delivery method. ### Recommended event flow | Customer action | Browser Pixel | Server-side CAPI | Notes | |---|---:|---:|---| | Views Arc Clip Lamp product page | Yes | Optional | Pixel is usually sufficient; CAPI can be added if required | | Adds Arc Clip Lamp to cart | Yes | Optional | Pixel is usually sufficient; CAPI can be added if required | | Begins checkout | Yes | Recommended | Useful funnel signal | | Completes paid order | Yes | Yes | Highest priority server-side event | For a small DTC Shopify store, prioritize reliable server-side delivery for **Purchase** first. Add server-side `InitiateCheckout`, `AddToCart`, and `ViewContent` only when there is a clear operational reason and a verified deduplication plan. --- ## 2. Standard events and required parameters Use Meta’s standard event names. Keep product identifiers consistent across Shopify, Meta, the product catalog, Pixel events, and CAPI events. For Cedar & Coil, the product is the **Arc Clip Lamp**, currently priced at **$68 USD**. ### Identifier convention Choose one durable product/variant identifier convention and use it everywhere. If using Shopify’s native Meta integration, let the integration manage catalog IDs and event IDs where possible. If implementing custom tracking, use the exact ID recognized by the Meta catalog. Do not assume that a Shopify product ID, variant ID, SKU, and Meta catalog ID are interchangeable. Common options include: - Shopify variant ID - SKU - A Meta catalog `retailer_id` - A Shopify-generated catalog identifier For a single-variant product, the event should still send a variant-level identifier if that is how the catalog is configured. --- ### `ViewContent` Send when a shopper views the Arc Clip Lamp product detail page. **Recommended parameters** ```json { "event_name": "ViewContent", "custom_data": { "content_ids": ["<arc_clip_lamp_variant_or_catalog_id>"], "content_type": "product", "content_name": "Arc Clip Lamp", "value": 68.00, "currency": "USD" } } ``` **Key fields** | Parameter | Purpose | |---|---| | `content_ids` | Product or variant/catalog ID used by Meta | | `content_type` | Usually `"product"` | | `content_name` | Human-readable product name; useful for diagnostics | | `value` | Product price shown or selected, such as `68.00` | | `currency` | ISO currency code, `"USD"` | Do not report misleading values. If a shopper is viewing a product at $68, report `68.00`, not a projected order value. --- ### `AddToCart` Send when the shopper successfully adds the Arc Clip Lamp to cart. **Recommended parameters** ```json { "event_name": "AddToCart", "custom_data": { "content_ids": ["<arc_clip_lamp_variant_or_catalog_id>"], "content_type": "product", "content_name": "Arc Clip Lamp", "contents": [ { "id": "<arc_clip_lamp_variant_or_catalog_id>", "quantity": 1, "item_price": 68.00 } ], "value": 68.00, "currency": "USD" } } ``` **Key fields** | Parameter | Purpose | |---|---| | `content_ids` | IDs of products added | | `contents` | Item-level purchase/cart detail | | `quantity` | Number of units added | | `item_price` | Per-unit price | | `value` | Cart value attributable to the event | | `currency` | `"USD"` | If the cart contains more than one item, include every relevant item in `contents`, send all corresponding `content_ids`, and calculate `value` from the relevant cart total. --- ### `InitiateCheckout` Send when the shopper begins Shopify checkout. **Recommended parameters** ```json { "event_name": "InitiateCheckout", "custom_data": { "content_ids": ["<arc_clip_lamp_variant_or_catalog_id>"], "content_type": "product", "contents": [ { "id": "<arc_clip_lamp_variant_or_catalog_id>", "quantity": 1, "item_price": 68.00 } ], "num_items": 1, "value": 68.00, "currency": "USD" } } ``` **Key fields** | Parameter | Purpose | |---|---| | `content_ids` | IDs of products in the checkout | | `contents` | Item-level checkout contents | | `num_items` | Total item quantity | | `value` | Checkout subtotal or the value convention Cedar & Coil consistently uses | | `currency` | `"USD"` | Choose and document a consistent value definition. For most ecommerce implementations, use the checkout subtotal/items value and exclude shipping and taxes unless the implementation is designed to report a different documented convention consistently. --- ### `Purchase` Send when Shopify confirms a completed, paid order. This is the most important event for purchase optimization and reporting. **Recommended parameters** ```json { "event_name": "Purchase", "custom_data": { "content_ids": ["<arc_clip_lamp_variant_or_catalog_id>"], "content_type": "product", "content_name": "Arc Clip Lamp", "contents": [ { "id": "<arc_clip_lamp_variant_or_catalog_id>", "quantity": 1, "item_price": 68.00 } ], "num_items": 1, "value": 68.00, "currency": "USD", "order_id": "<shopify_order_id_or_name>" } } ``` **Required purchase details to include** | Parameter | Requirement | |---|---| | `value` | Send the actual completed order value, as a number | | `currency` | Send ISO currency code, such as `"USD"` | | `content_ids` | Include purchased product/variant/catalog IDs | | `contents` | Include item IDs, quantities, and item prices | | `order_id` | Strongly recommended for reconciliation and debugging | | `event_id` | Required for browser/server deduplication when both send Purchase | For the Arc Clip Lamp sold at its stated price with one unit and no other adjustments, the item value would be `68.00` and currency would be `"USD"`. For actual orders, use Shopify’s final order data rather than hard-coding $68. --- ## 3. Exactly how Pixel/CAPI deduplication works When both the browser Pixel and CAPI report the same customer action, Meta needs to know they represent **one event**, not two. ### The deduplication rule For a browser and server event to be deduplicated, they must use: - The same Meta **Pixel/Dataset** - The same `event_name` - The same `event_id` For example: ```text Browser Pixel: event_name = Purchase event_id = purchase_987654321 Server CAPI: event_name = Purchase event_id = purchase_987654321 ``` Meta receives both reports, recognizes the matching event name and event ID, and counts them as one Purchase event. ### What must not happen Do not generate unrelated IDs independently: ```text Browser Pixel: purchase_browser_abc123 CAPI: purchase_server_xyz789 ``` Those are two different event IDs. Meta may count them as two purchases. Do not reuse one event ID for multiple different purchases: ```text purchase_event purchase_event purchase_event ``` Each conversion action needs its own unique ID. ### Practical event-ID pattern Use a deterministic ID for Purchase based on the Shopify order: ```text purchase_<shopify_order_id> ``` Example: ```text purchase_58732491 ``` This makes it possible for: - The Shopify thank-you/checkout-completed browser event - The Shopify `orders/paid` webhook or server-side order handler to independently derive the same Purchase event ID. For other events, generate an ID when the event occurs and preserve it if the same event will be sent both browser-side and server-side: ```text viewcontent_<uuid> addtocart_<uuid> initiatecheckout_<checkout_token> ``` ### Deduplication implementation pattern 1. Browser generates or receives an event ID. 2. Browser sends a Pixel event with that ID. 3. The same ID is stored or made available to the server. 4. Server sends the CAPI version with the same event name and event ID. 5. Meta deduplicates the pair. ### Pixel example ```javascript fbq( "track", "Purchase", { value: 68.00, currency: "USD", content_ids: ["<arc_clip_lamp_variant_or_catalog_id>"], content_type: "product" }, { eventID: "purchase_58732491" } ); ``` ### Important implementation note If Cedar & Coil uses the native Shopify Meta integration, do not add a second custom Purchase implementation unless there is a documented need and a tested deduplication design. Otherwise, the store can create duplicate event streams. --- ## 4. Preparing customer information for server-side events CAPI supports customer information parameters in `user_data`. These parameters can improve Meta’s ability to match a server event to a Meta user when permitted and available. Only send information that Cedar & Coil is allowed to process and share under its consent, privacy, and legal requirements. ### Hash personally identifiable information before sending For server-side CAPI requests, normalize and SHA-256 hash eligible customer fields before sending them. Common fields include: | CAPI field | Source | Preparation | |---|---|---| | `em` | Customer email | Lowercase, trim whitespace, SHA-256 hash | | `ph` | Customer phone | Normalize to E.164 digits, SHA-256 hash | | `fn` | First name | Lowercase, trim, SHA-256 hash | | `ln` | Last name | Lowercase, trim, SHA-256 hash | | `ct` | City | Lowercase, trim, SHA-256 hash | | `st` | State/region | Lowercase, trim, SHA-256 hash | | `zp` | Postal code | Normalize, SHA-256 hash | | `country` | Country | Normalize to two-letter code where applicable, SHA-256 hash | | `external_id` | Cedar & Coil customer ID | Stable internal ID, SHA-256 hash | Example email normalization: ```text Original: Jamie.Example@Email.com Normalized: jamie.example@email.com SHA-256: <hashed_result> ``` ### Do not hash these fields Some browser and request context fields should normally be sent in their original form, not SHA-256 hashed: | Field | Handling | |---|---| | `client_ip_address` | Send raw IP address received by Cedar & Coil’s server | | `client_user_agent` | Send raw browser user-agent string | | `fbp` | Send raw `_fbp` cookie value, if available and consented | | `fbc` | Send raw click ID derived from `fbclid`, if available and consented | ### Capture Meta browser identifiers when available For stronger browser-to-server continuity, collect and pass: - `_fbp`: Meta browser ID cookie - `_fbc`: Meta click ID cookie, generally derived when a visitor arrives with an `fbclid` URL parameter - Client IP address - Client user agent The native Shopify Meta integration may manage much of this automatically. In a custom build, capture these values on the storefront and associate them with the cart, checkout, or order where permitted. ### Data quality rules - Do not send placeholder customer information. - Do not send unverified or fabricated emails, phone numbers, or addresses. - Do not send raw email addresses or phone numbers in CAPI `user_data`. - Do not put sensitive health, financial, or similarly sensitive data into event parameters. - Do not treat hashing as anonymization or as a substitute for consent. ### Security rules - Keep the CAPI access token server-side only. - Never expose the token in storefront JavaScript, Shopify theme code, or public repositories. - Restrict access to the Meta system user/token used for CAPI. - Rotate tokens and review access when personnel or vendors change. --- ## 5. Concrete Shopify setup path ### Option A: Native Shopify Meta sales channel app For a small DTC store such as Cedar & Coil, this is the recommended starting point. Use Shopify’s **Facebook & Instagram by Meta** sales channel/app, subject to the current Shopify and Meta availability in Cedar & Coil’s selling region. #### Why this is recommended The native integration is generally the lowest-risk path because it can: - Install/manage the Meta Pixel without manually editing theme code - Connect Shopify product data to Meta catalog infrastructure - Send ecommerce events such as product views, cart events, checkout events, and purchases - Support server-side event sharing through Meta’s Conversions API capabilities - Reduce the need to build and maintain Shopify checkout tracking code - Handle Shopify platform changes more safely than custom thank-you-page scripts #### Typical setup path 1. In Shopify admin, open **Apps** or **Sales channels**. 2. Install or open **Facebook & Instagram by Meta**. 3. Connect the correct Meta business portfolio/business account. 4. Connect the correct Facebook Page and Instagram account, if applicable. 5. Connect the Meta ad account Cedar & Coil will use. 6. Select or create the correct Meta Pixel/Dataset. 7. Configure product catalog synchronization. 8. Open the app’s **Settings** or **Data sharing** section. 9. Select the highest data-sharing level that Cedar & Coil can lawfully use after its consent configuration is in place. Shopify’s labels may vary by version and region; verify that the configuration includes both browser Pixel and server-side CAPI sharing where available. 10. Confirm the correct Pixel/Dataset ID in Meta Events Manager. 11. Do not separately paste a second base Pixel into the Shopify theme unless required and deliberately designed to avoid duplication. #### Native-app implementation checks Before considering this complete, verify: - One intended Meta Pixel/Dataset is receiving events. - Shopify catalog IDs align with event `content_ids`. - Purchase is firing once per paid order. - Events Manager shows browser and server event sources where expected. - Meta reports Purchase deduplication rather than duplicate Purchase events. - Consent behavior works correctly for visitors who decline optional marketing tracking. --- ### Option B: Custom Pixel + custom CAPI implementation Use a custom implementation only if Cedar & Coil has a requirement the native integration cannot satisfy, such as: - A custom storefront/headless Shopify build - A nonstandard checkout or order flow - A proprietary customer data platform - Custom event logic beyond Shopify’s native setup - A need to control the exact server event payload and data pipeline #### Custom implementation components A robust custom implementation usually includes: 1. **Browser tracking** - Meta Pixel loaded through Shopify’s supported customer events/pixel framework or a carefully managed theme integration. - Event IDs generated or derived consistently. - Event data captured for product, cart, checkout, and purchase activity. 2. **Server endpoint or event service** - Receives browser context where appropriate, such as `_fbp`, `_fbc`, user agent, and event IDs. - Stores only data Cedar & Coil is permitted to retain. - Hashes customer identity fields. - Sends CAPI requests securely. 3. **Shopify webhooks** - For Purchase, use a trusted Shopify order/payment event such as `orders/paid`, depending on Cedar & Coil’s order lifecycle and fulfillment/payment rules. - Validate Shopify webhook signatures. - Make the event processor idempotent so webhook retries do not create duplicate CAPI events. 4. **Shared event-ID strategy** - Browser Purchase and server Purchase must use the same `event_id`. - A deterministic ID derived from the Shopify order ID is often practical. 5. **Retry and logging** - Record the Shopify order ID, Meta event ID, request timestamp, and Meta response. - Retry transient failures safely. - Do not resend successful events indefinitely. ### Native app versus custom: recommendation | Factor | Native Shopify Meta app | Custom implementation | |---|---|---| | Initial setup effort | Lower | Higher | | Shopify checkout compatibility | Stronger by default | Requires active maintenance | | CAPI support | Usually available through app settings | Full control, but must build | | Product catalog alignment | Easier | Must be designed and tested | | Custom business logic | Limited | High | | Ongoing engineering burden | Lower | Higher | | Recommended for Cedar & Coil now | **Yes** | Only if needed | **Recommendation:** Start with the native Shopify Meta sales channel/app, configure browser and server-side sharing, and validate it thoroughly. Add a custom CAPI service only if Cedar & Coil later has a documented tracking requirement that the native setup cannot meet. --- ### Server-side Purchase CAPI request: code sketch The following Node.js-style example illustrates a server-side Purchase event after Shopify confirms a paid order. It is a sketch, not drop-in production code. Use a currently supported Graph API version in place of `vXX.X`. ```javascript import crypto from "node:crypto"; const META_PIXEL_ID = process.env.META_PIXEL_ID; const META_CAPI_ACCESS_TOKEN = process.env.META_CAPI_ACCESS_TOKEN; const META_API_VERSION = "vXX.X"; function sha256(value) { if (!value) return undefined; return crypto .createHash("sha256") .update(String(value).trim().toLowerCase()) .digest("hex"); } async function sendPurchaseToMeta(order, trackingContext = {}) { // Use a deterministic event ID that browser Purchase can also use. const eventId = `purchase_${order.id}`; const contents = order.line_items.map((item) => ({ // Must match the ID convention used in Meta catalog/event tracking. id: String(item.variant_id), quantity: item.quantity, item_price: Number(item.price) })); const contentIds = order.line_items.map((item) => String(item.variant_id)); const userData = { em: sha256(order.email), ph: order.phone ? sha256(order.phone.replace(/\D/g, "")) : undefined, fn: order.customer?.first_name ? sha256(order.customer.first_name) : undefined, ln: order.customer?.last_name ? sha256(order.customer.last_name) : undefined, ct: order.billing_address?.city ? sha256(order.billing_address.city) : undefined, st: order.billing_address?.province_code ? sha256(order.billing_address.province_code) : undefined, zp: order.billing_address?.zip ? sha256(order.billing_address.zip) : undefined, country: order.billing_address?.country_code ? sha256(order.billing_address.country_code) : undefined, // These are not hashed. Only include when lawfully collected and available. fbp: trackingContext.fbp, fbc: trackingContext.fbc, client_ip_address: trackingContext.clientIp, client_user_agent: trackingContext.userAgent }; // Remove undefined properties before sending. Object.keys(userData).forEach( (key) => userData[key] === undefined && delete userData[key] ); const payload = { data: [ { event_name: "Purchase", event_time: Math.floor( new Date(order.processed_at || order.created_at).getTime() / 1000 ), event_id: eventId, action_source: "website", event_source_url: trackingContext.eventSourceUrl, user_data: userData, custom_data: { currency: order.currency || "USD", value: Number(order.current_total_price), content_type: "product", content_ids: contentIds, contents, num_items: order.line_items.reduce( (sum, item) => sum + item.quantity, 0 ), order_id: String(order.id) } } ] }; const endpoint = `https://graph.facebook.com/${META_API_VERSION}/` + `${META_PIXEL_ID}/events?access_token=${META_CAPI_ACCESS_TOKEN}`; const response = await fetch(endpoint, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(payload) }); const result = await response.json(); if (!response.ok) { throw new Error(`Meta CAPI error: ${JSON.stringify(result)}`); } return result; } ``` ### Production notes for the code sketch - Verify Shopify webhook signatures before processing the order. - Use the actual paid-order total from Shopify, not the catalog price. - Ensure `content_ids` match the Meta catalog’s IDs. - Send events promptly after the action occurs. - Store a processed-order/event record so webhook retries do not create repeated server events. - Send `test_event_code` only during testing; remove it from production requests. - Do not use raw personally identifiable information in `user_data`. - Ensure the browser Purchase event uses the same `event_id`, such as `purchase_<order.id>`. --- ## 6. Validate end to end before scaling spend Do not rely on a successful installation message alone. Validate the whole customer journey with test traffic and a real or test payment flow appropriate to Cedar & Coil’s Shopify configuration. ### A. Confirm base Pixel loading Use Meta Pixel Helper or browser developer tools to verify that: - The intended Meta Pixel/Dataset ID loads on the storefront. - There is not an unexpected second Pixel installed in theme code, a tag manager, or another app. - The Arc Clip Lamp product page sends a `ViewContent` event. - Browser console errors are not preventing event delivery. ### B. Test the funnel step by step Run a test journey: 1. Open the Arc Clip Lamp product page. 2. Confirm `ViewContent`. 3. Add one Arc Clip Lamp to cart. 4. Confirm `AddToCart`. 5. Begin checkout. 6. Confirm `InitiateCheckout`. 7. Complete a test order or controlled order. 8. Confirm `Purchase`. For each event, inspect: - Event name - Pixel/Dataset ID - Event timestamp - `value` - `currency` - `content_ids` - `contents` - `event_id` - Browser versus server source - Whether the event appears once, not multiple times ### C. Use Meta Events Manager Test Events In Meta Events Manager: 1. Open the intended Pixel/Dataset. 2. Go to **Test Events**. 3. Generate or use a test event code for CAPI testing. 4. Send test server events with that code. 5. Visit the Shopify storefront in a test session. 6. Confirm browser events and server events appear. 7. Inspect event payload warnings and parameter diagnostics. A successful API response only means Meta accepted the request format. It does not automatically prove that IDs match the catalog, customer information was prepared correctly, or browser/server events were deduplicated. ### D. Verify Purchase deduplication For one controlled purchase: - Confirm the browser sends `Purchase` with an event ID. - Confirm CAPI sends `Purchase` with the same event ID. - Confirm both are sent to the same Pixel/Dataset. - Review Events Manager diagnostics for deduplication behavior. - Ensure reporting does not show two Purchase events from the single order. Keep a simple test log: | Test order | Browser Purchase event ID | CAPI Purchase event ID | Expected result | |---|---|---|---| | Test order 1 | `purchase_58732491` | `purchase_58732491` | One deduplicated Purchase | ### E. Verify catalog matching Inspect whether `content_ids` sent in `ViewContent`, `AddToCart`, `InitiateCheckout`, and `Purchase` correspond to catalog items. If IDs do not match: - Dynamic ads and catalog-based reporting may not work as intended. - Event payloads may appear valid while product-level matching is incomplete. - Fix identifier mapping before scaling catalog or conversion campaigns. ### F. Test consent states Test at least two visitor states: 1. **Visitor grants applicable marketing consent** - Confirm Pixel/CAPI behavior follows Cedar & Coil’s approved configuration. 2. **Visitor declines applicable marketing consent** - Confirm optional tracking does not fire or is limited according to Cedar & Coil’s legal and consent configuration. Also test a returning visitor whose consent preference changes. ### G. Monitor after launch For the first days of activity, review: - Event volume by event type - Browser versus server event sources - Purchase deduplication diagnostics - Event matching diagnostics - CAPI error responses - Shopify paid-order count compared with sent Purchase event count - Unexpected duplicate Purchases - Catalog/event ID warnings Do not judge implementation quality solely by a single attribution metric. Use technical event diagnostics and Shopify order reconciliation alongside Meta reporting. --- ## 7. Consent and compliance note Cedar & Coil must configure tracking according to applicable privacy, cookie, marketing, consumer-protection, and platform requirements. Requirements vary by customer location and may include consent obligations for advertising cookies, cross-site tracking, and server-side sharing. ### Minimum operating principles - Obtain required consent before enabling nonessential marketing tracking. - Make consent choices clear and accessible. - Honor opt-outs and preference changes. - Do not send CAPI events as a workaround for a user declining tracking consent. - Explain relevant data sharing in Cedar & Coil’s privacy notice. - Use an appropriate consent-management platform or Shopify-compatible consent mechanism where needed. - Configure Meta data-use settings, including any applicable limited-data-use or regional settings, with legal guidance. - Limit event data to what is necessary for measurement and advertising purposes. - Keep Meta access tokens and customer data secure. - Establish data-retention, vendor-access, and incident-response practices appropriate to Cedar & Coil’s business. Hashing customer information before a CAPI request is a Meta technical requirement for supported identity fields; it does not remove Cedar & Coil’s privacy obligations or turn personal information into non-personal information for legal purposes. Before launch, Cedar & Coil should have its privacy and consent configuration reviewed by the person or adviser responsible for its compliance program.
Score · attempt 2 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.
✓The guide explicitly recommends a hybrid of browser Pixel + server-side CAPI with deduplication and explains browser privacy limitations (Safari, ad blockers, cookie restrictions) as the reason 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.
✓ViewContent, AddToCart, InitiateCheckout, and Purchase are each given JSON parameter examples, with Purchase explicitly including 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 sendPurchaseToMeta function payload includes event_name: 'Purchase', event_time (Unix seconds), event_id, 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 6C instructs using Meta Events Manager's Test Events tool, and section 6D explicitly verifies that browser and server Purchase events share an event_id and checks that reporting shows a single deduplicated Purchase rather than two.
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 event-flow table labels browser vs server firing per event, and the custom implementation section states Purchase should use a trusted Shopify order/payment event such as 'orders/paid' as the source of truth rather than only the browser 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.
✓No attribution-recovery percentages are promised anywhere, and the consent section states CAPI events must not be sent as a workaround for declined tracking consent and requires regional privacy compliance.
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 the same Pixel/Dataset, event_name, and event_id must match on both Pixel and CAPI sends for Meta to treat them as one event, with concrete matching/non-matching examples.
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 recommends a deterministic event_id like `purchase_<shopify_order_id>` and explicitly requires the event processor be idempotent so 'webhook retries do not create duplicate CAPI events.'
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(order.processed_at || order.created_at).getTime() / 1000)`, deriving it from the order's actual timestamp rather than the current send time, so it stays 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 sha256 helper trims and lowercases the value before hashing, and the table instructs 'Lowercase, trim whitespace, SHA-256 hash' for email 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 ('Start with the native Shopify Meta sales channel/app...') with a numbered concrete setup path (steps 1-11) rather than leaving the options undifferentiated.
✗ Attempt 3
Answer · attempt 3 the model's full response$0.094 · 91.6s · 7.8k tok
# Cedar & Coil Meta Conversion Tracking Implementation Guide This guide covers a resilient tracking setup for Cedar & Coil’s Shopify store and Arc Clip Lamp campaigns. The goal is to send reliable conversion signals to Meta while accounting for browser privacy controls, ad blockers, cookie restrictions, and incomplete client-side tracking. ## 1. Recommended architecture: Meta Pixel + Conversions API Use both: 1. **Meta Pixel in the browser** 2. **Meta Conversions API (CAPI) from the server** 3. **Shared event IDs for deduplication** ### Browser layer: Meta Pixel The Pixel records events directly in the shopper’s browser, such as: - Product-page views - Add-to-cart actions - Checkout starts - Purchases It can capture browser-side context that is useful to Meta, including the `_fbp` browser identifier, the `_fbc` click identifier when available, page URL, and user agent. However, browser events are not fully reliable. They can be limited by: - Browser tracking prevention - Cookie restrictions - Ad blockers - Network failures - Consent choices - Users moving between devices or browsers ### Server layer: Conversions API Conversions API sends events from Cedar & Coil’s server or Shopify-connected integration to Meta’s server endpoint. This gives Meta a second signal source that does not depend entirely on the shopper’s browser successfully loading and sending a Pixel event. For a Purchase, the server can send reliable order data such as: - Shopify order ID - Order total - Currency - Purchased variant IDs - Quantity - Customer information, where consent and applicable law permit - Event timestamp CAPI is not a replacement for the Pixel. It complements the Pixel. ### Why both are needed | Capability | Browser Pixel | Server-side CAPI | |---|---:|---:| | Captures on-page behavior quickly | Yes | Sometimes, depending on implementation | | Can access browser IDs such as `_fbp` and `_fbc` | Yes | Only if passed from browser/storefront | | More resistant to ad blockers and browser restrictions | No | More so | | Receives authoritative paid-order data | Limited | Yes | | Supports Meta matching and optimization | Yes | Yes | | Requires deduplication when both send the same event | Yes | Yes | **Recommended architecture for Cedar & Coil:** ```text Shopper browser ├─ Meta Pixel sends ViewContent, AddToCart, InitiateCheckout, Purchase └─ Browser IDs / consent state are available where permitted Shopify / Cedar & Coil server ├─ Sends Purchase through Conversions API ├─ Uses Shopify order data as the source of truth ├─ Sends permitted customer matching fields └─ Uses the same event_id as the browser Purchase event Meta └─ Deduplicates matching browser and server events ``` For a small DTC Shopify store, use Meta’s Shopify integration first rather than building all of this from scratch. See Section 5. --- ## 2. Standard events and required parameters Use Meta standard events throughout the Arc Clip Lamp funnel: 1. `ViewContent` 2. `AddToCart` 3. `InitiateCheckout` 4. `Purchase` Use the same product-ID convention across: - Shopify product/catalog feed - Browser Pixel events - Conversions API events - Meta catalog, if Cedar & Coil runs catalog or dynamic-product ads later For Shopify stores, the safest convention is usually the **Shopify variant ID**, provided the Meta catalog also uses that same ID. Do not mix product handles, product IDs, SKU values, and variant IDs without a deliberate mapping. For the Arc Clip Lamp, use the current selected sellable variant ID, even if the store has only one variant today. ### Event parameter table | Event | When it fires | Key parameters | |---|---|---| | `ViewContent` | Product page is viewed | `content_ids`, `content_type`, `contents`, `value`, `currency`, optionally `content_name` | | `AddToCart` | Shopper adds the lamp to cart | `content_ids`, `content_type`, `contents`, `value`, `currency` | | `InitiateCheckout` | Shopper begins Shopify checkout | `content_ids`, `content_type`, `contents`, `value`, `currency`, `num_items` | | `Purchase` | Order is successfully completed/paid | `content_ids`, `content_type`, `contents`, `value`, `currency`, `order_id`, `event_id` | ### Recommended event payload fields #### `ViewContent` Fire on the Arc Clip Lamp product page after product data is available. ```javascript fbq('track', 'ViewContent', { 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' }); ``` Use the live Shopify product price rather than hard-coding `$68` in production code. #### `AddToCart` Fire only after the item is successfully added to Shopify cart, not merely when the shopper clicks the button. ```javascript fbq('track', 'AddToCart', { content_ids: ['SHOPIFY_VARIANT_ID'], content_type: 'product', contents: [ { id: 'SHOPIFY_VARIANT_ID', quantity: 1, item_price: 68.00 } ], value: 68.00, currency: 'USD' }); ``` If the cart includes multiple items later, send all eligible items in `contents` and set `value` to the relevant cart value. #### `InitiateCheckout` Fire when the shopper starts the Shopify checkout process. ```javascript fbq('track', 'InitiateCheckout', { content_ids: ['SHOPIFY_VARIANT_ID'], content_type: 'product', contents: [ { id: 'SHOPIFY_VARIANT_ID', quantity: 1, item_price: 68.00 } ], num_items: 1, value: 68.00, currency: 'USD' }); ``` For a multi-item checkout, include each item in `contents`, include all corresponding IDs in `content_ids`, and make `value` equal the checkout/cart total being represented. #### `Purchase` Fire only once for a successfully completed order. It must include: - `value` - `currency` - `content_ids` - `contents` - A stable `order_id` - A shared `event_id` when browser Pixel and CAPI both send the Purchase ```javascript 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: 'purchase_SHOPIFY_ORDER_ID' }); ``` ### Important implementation rules - Use `USD` as the currency for Cedar & Coil’s current US-dollar storefront. If the store supports other currencies later, send the actual transaction currency. - Use numeric values, not formatted currency strings. Send `68.00`, not `"$68.00"`. - `content_ids` should be an array. - `contents` should be an array of objects with at least `id` and `quantity`; include `item_price` where possible. - Do not fire `Purchase` from a generic “thank you” page view unless the implementation protects against page refreshes and repeat visits. - The server-side order event should be the source of truth for whether the order is actually paid or completed. --- ## 3. How Pixel/CAPI deduplication works When both the browser Pixel and CAPI send the same conversion, Meta needs to recognize that they represent one customer action, not two. This is called **deduplication**. ### The rule For the same conversion, send: - The same `event_name` - The same `event_id` Example: | Source | Event name | Event ID | |---|---|---| | Browser Pixel | `Purchase` | `purchase_1234567890` | | Server CAPI | `Purchase` | `purchase_1234567890` | Meta can then treat those records as one Purchase event. ### Browser Pixel format The Pixel uses `eventID`: ```javascript fbq('track', 'Purchase', purchaseData, { eventID: 'purchase_1234567890' }); ``` ### CAPI format The server payload uses `event_id`: ```json { "event_name": "Purchase", "event_id": "purchase_1234567890" } ``` The value must be identical. ### Recommended event ID convention For Purchase events, use a stable Shopify order identifier: ```text purchase_{shopify_order_id} ``` Example: ```text purchase_1234567890 ``` The exact format is not important. Consistency is. Do not use: - A new random ID generated separately in the browser and server - A timestamp alone - The customer’s email address - A reusable event ID shared across multiple orders ### Practical Purchase flow ```text 1. Shopify confirms order completion. 2. Browser Purchase event sends: event_name = Purchase eventID = purchase_{order_id} 3. Shopify webhook or order-processing service sends CAPI: event_name = Purchase event_id = purchase_{order_id} 4. Meta receives both and deduplicates them. ``` ### Deduplication mistakes to avoid 1. **Different IDs** - Browser: `purchase_123` - Server: `order_123` - Result: Meta may treat them as two Purchases. 2. **Different event names** - Browser: `Purchase` - Server: `OrderCompleted` - Result: no standard-event deduplication. 3. **Sending two server Purchase events** - For example, one from an order-created webhook and one from an order-paid webhook. - Pick one authoritative trigger, usually a paid/completed order state appropriate to the store’s payment flow. 4. **Adding a custom Purchase event on top of Shopify’s managed Meta integration** - If the native Shopify Meta integration already sends Purchase through CAPI, do not independently add another CAPI Purchase implementation unless you have intentionally replaced or disabled the managed implementation. 5. **Using separate Pixel IDs** - Browser and CAPI events intended for deduplication should be associated with the same Meta Pixel/data set. --- ## 4. Preparing customer information for server-side events CAPI can include customer information to help Meta match the server event to a Meta user. Only send data that Cedar & Coil is permitted to use under its privacy policy, consent settings, customer expectations, Shopify configuration, and applicable law. ### Customer information commonly used for matching Where available and permitted, CAPI `user_data` may include: - `em`: email address - `ph`: phone number - `fn`: first name - `ln`: last name - `ct`: city - `st`: state or region - `zp`: ZIP/postal code - `country`: country - `external_id`: Cedar & Coil’s internal customer identifier or Shopify customer ID - `fbp`: Meta browser ID from the `_fbp` cookie - `fbc`: Meta click ID derived from `fbclid`, when present - `client_ip_address` - `client_user_agent` Not every event will have every field. Send only accurate fields you actually have. ### Hashing rules For CAPI, personally identifiable matching fields must generally be normalized and SHA-256 hashed before transmission. Typically hash: - Email - Phone number - First name - Last name - City - State - ZIP/postal code - Country - External ID Do not hash these fields: - `fbp` - `fbc` - `client_ip_address` - `client_user_agent` ### Normalization examples Before hashing: | Field | Normalize before SHA-256 hashing | |---|---| | Email | Trim spaces and lowercase | | Phone | Convert to a consistent international/E.164-style number where possible; remove spaces and punctuation | | Names | Trim, lowercase, remove unexpected formatting where appropriate | | Country | Use a consistent two-letter country code, such as `us` | | State | Use a consistent normalized state/region value | | ZIP/postal code | Normalize formatting consistently | | External ID | Use a stable Cedar & Coil or Shopify customer identifier; do not use a random per-event value | Example: ```text Raw email: " Customer@Example.com " Normalized email: "customer@example.com" SHA-256: [hash of normalized value] ``` ### Preserve browser identifiers when possible The `_fbp` and `_fbc` values can materially improve the connection between browser and server events when they are available and consent permits their use. - `_fbp`: Meta browser identifier set by the Pixel. - `_fbc`: Meta click identifier, generally derived from the `fbclid` query parameter after an ad click. A custom server implementation needs a compliant way to pass these values from the browser to the backend or store them with the checkout/order. Do not invent them if they are missing. ### Data minimization and security - Do not put raw customer data in URLs, client-side logs, analytics debug tools, or order notes visible to staff unless necessary and appropriately protected. - Keep the CAPI access token server-side only. - Never expose the access token in theme JavaScript, Shopify Liquid, browser network calls, or a public Git repository. - Use only the customer fields needed for legitimate measurement and matching purposes. --- ## 5. Shopify setup path: native Meta app vs. custom implementation ## Option A: Native Shopify Meta integration For most small Shopify DTC stores, use Shopify’s official **Facebook & Instagram by Meta** sales channel/app as the primary implementation. The exact labels in Shopify can change, but the general path is: ```text Shopify Admin → Sales channels / Apps → Facebook & Instagram by Meta → Connect Meta Business Portfolio → Connect Facebook Page → Connect Meta ad account → Connect or create Meta Pixel / data set → Connect catalog → Configure customer data sharing ``` ### Recommended native setup steps 1. **Install or open Facebook & Instagram by Meta** - In Shopify Admin, add the official Meta sales channel if it is not already installed. 2. **Connect the correct Meta business assets** - Meta Business Portfolio - Facebook Page, if applicable - Instagram account, if applicable - Ad account - Pixel/data set - Commerce catalog 3. **Select the correct Pixel/data set** - Use one production Pixel/data set for the live Cedar & Coil storefront. - Do not create multiple production Pixels unless there is a clear business reason. 4. **Set customer data sharing to the highest appropriate setting** - Shopify commonly presents levels such as Conservative, Enhanced, or Maximum. - The highest setting generally enables broader browser and server-side sharing functionality, including Meta’s server-side integration features. - Select only the level supported by Cedar & Coil’s consent and legal configuration. 5. **Connect the Shopify catalog** - Ensure the Arc Clip Lamp and its sellable variant(s) are approved and available in the Meta catalog. - Confirm that the product IDs in Meta match the IDs the integration uses in events. 6. **Verify the Cedar & Coil domain in Meta** - In Meta Business Settings, verify the store domain using the available verification method. - Domain verification supports event configuration and protects the brand’s domain ownership in Meta. 7. **Configure Aggregated Event Measurement, if applicable** - In Meta Events Manager, prioritize web conversion events for the verified domain. - A typical order is: 1. `Purchase` 2. `InitiateCheckout` 3. `AddToCart` 4. `ViewContent` 8. **Do not add duplicate theme Pixel code** - If the Meta Shopify integration is managing the Pixel, avoid also pasting separate base Pixel code into `theme.liquid` or a tag manager without a clear plan. - Duplicate base code is a common cause of repeated events. ### Why this is the recommended approach for Cedar & Coil For a small DTC Shopify store, the native integration is usually the best starting point because it: - Reduces implementation time - Handles many Shopify-to-Meta mappings automatically - Can provide managed browser and server-side event transmission - Reduces the risk of accidental checkout incompatibilities - Reduces the need to store and process order/customer data in a separate custom service - Is easier for a technical marketer to maintain Before launching, verify in Events Manager that the integration is sending both browser and server event sources where expected. App behavior and available settings can vary by Shopify plan, market, integration version, and Meta account configuration. --- ## Option B: Custom Pixel + custom CAPI implementation A custom implementation is appropriate when Cedar & Coil needs capabilities the native app does not provide, such as: - A custom order-management or subscription system - Nonstandard checkout or post-purchase flows - Custom event enrichment from internal systems - A first-party server-side tracking architecture - Explicit control over event IDs, payloads, and retry handling - Multi-store or multi-region data routing ### Custom implementation components A custom implementation typically requires: 1. **Browser tracking** - Meta Pixel base code or Shopify customer pixel setup - Standard-event tracking for product, cart, checkout, and purchase actions - Consent-aware behavior - Shared Purchase event IDs 2. **Server endpoint** - A secure application endpoint or serverless function - Meta CAPI access token stored in server secrets - Payload validation and error logging - Retry handling for transient Meta API failures 3. **Shopify order trigger** - Usually a Shopify webhook, such as an order-paid or order-completed workflow appropriate to the payment flow - Webhook signature verification - Idempotency protection so the same order does not create duplicate CAPI events 4. **Identifier persistence** - A compliant mechanism to preserve `fbp`, `fbc`, and the shared `event_id` from browser/checkout context through order creation where possible 5. **Catalog ID mapping** - A documented mapping between Shopify variants and Meta catalog item IDs ### Native vs. custom comparison | Consideration | Native Meta Shopify integration | Custom implementation | |---|---|---| | Initial setup effort | Lower | Higher | | Ongoing maintenance | Lower | Higher | | Control of payloads and logic | Limited | High | | Checkout compatibility | Usually managed | Must be tested carefully | | CAPI access and retry logic | Managed by integration | Cedar & Coil must build it | | Best fit for Cedar & Coil now | Yes | Only if there is a specific requirement | ### Recommendation **Start with the official Shopify Meta integration for Cedar & Coil.** Use a custom implementation only if the native integration cannot meet a documented business or technical requirement. If a custom CAPI implementation is introduced later, first decide whether it will: - Replace the managed Meta CAPI Purchase event, or - Add only genuinely new events not already sent by the integration. Do not run two independent Purchase CAPI pipelines against the same Pixel without deliberate deduplication and ownership rules. --- ### Code sketch: server-side Purchase event request The following Node.js-style example illustrates what a custom CAPI Purchase event can look like. It assumes: - A verified Shopify webhook has delivered a paid/completed order. - The browser Purchase event uses the same ID: `purchase_{order_id}`. - Customer data has been normalized and SHA-256 hashed before use. - The Meta access token is stored in a server-side environment variable. - Product IDs match the IDs used in the Meta catalog. ```javascript import crypto from "node:crypto"; const META_PIXEL_ID = process.env.META_PIXEL_ID; const META_ACCESS_TOKEN = process.env.META_ACCESS_TOKEN; const GRAPH_API_VERSION = process.env.META_GRAPH_API_VERSION || "vXX.X"; function sha256(value) { if (!value) return undefined; return crypto .createHash("sha256") .update(String(value).trim().toLowerCase()) .digest("hex"); } async function sendPurchaseToMeta(order) { const eventId = `purchase_${order.id}`; const contents = order.line_items.map((item) => ({ // Use the exact identifier that matches the Meta catalog item ID. id: String(item.variant_id), quantity: Number(item.quantity), item_price: Number(item.price) })); const contentIds = contents.map((item) => item.id); const userData = { // Hash normalized PII fields before sending. em: order.email ? [sha256(order.email)] : undefined, ph: order.phone ? [sha256(order.phone)] : undefined, // Use a stable ID where permitted; hash it before sending. external_id: order.customer?.id ? [sha256(String(order.customer.id))] : undefined, // These are not hashed. Send only when accurately collected and permitted. client_ip_address: order.client_details?.browser_ip, client_user_agent: order.client_details?.user_agent, // Populate from a compliant first-party capture process if available. // fbp: order.attributes?.fbp, // fbc: order.attributes?.fbc }; // Remove empty values so the payload is clean. Object.keys(userData).forEach((key) => { if ( userData[key] === undefined || userData[key] === null || userData[key] === "" ) { delete userData[key]; } }); const payload = { data: [ { event_name: "Purchase", event_time: Math.floor(Date.now() / 1000), event_id: eventId, event_source_url: "https://cedarandcoil.com/", action_source: "website", user_data: userData, custom_data: { currency: order.currency || "USD", value: Number(order.total_price), content_type: "product", content_ids: contentIds, contents, order_id: String(order.id), num_items: contents.reduce( (total, item) => total + item.quantity, 0 ) } } ] // Add test_event_code here only during Events Manager test validation. // test_event_code: process.env.META_TEST_EVENT_CODE }; const response = await fetch( `https://graph.facebook.com/${GRAPH_API_VERSION}/${META_PIXEL_ID}/events?access_token=${META_ACCESS_TOKEN}`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(payload) } ); const responseBody = await response.json(); if (!response.ok) { throw new Error( `Meta CAPI Purchase failed: ${JSON.stringify(responseBody)}` ); } return responseBody; } ``` ### Custom implementation safeguards If building custom CAPI: - Verify Shopify webhook signatures. - Use idempotency controls keyed on Shopify order ID and event type. - Store whether a CAPI event was successfully sent. - Retry temporary API/network failures. - Do not retry indefinitely without controls. - Avoid logging raw emails, phone numbers, access tokens, or complete customer records. - Use a current supported Meta Graph API version rather than leaving `vXX.X` in production. - Treat order value, item data, and currency from Shopify as the source of truth. --- ## 6. Validate end to end before scaling ad spend Do not treat an installed app or visible Pixel ID as proof that tracking works. Validate each event from storefront action through Meta receipt. ## A. Build a test checklist Test the Arc Clip Lamp customer path: ```text Product page → Add Arc Clip Lamp to cart → Begin checkout → Complete a test order → Confirm browser and server events in Meta → Confirm Purchase is deduplicated ``` Use a Shopify test payment method or test order workflow where available. Do not rely on a real customer order as the first implementation test. ## B. Test in Meta Events Manager In **Meta Events Manager**: 1. Select Cedar & Coil’s Pixel/data set. 2. Open **Test Events**. 3. Visit the live or staging storefront in a separate browser session. 4. Perform the funnel actions: - View the Arc Clip Lamp - Add it to cart - Start checkout - Complete a test purchase 5. Confirm the standard events appear: - `ViewContent` - `AddToCart` - `InitiateCheckout` - `Purchase` For custom CAPI testing, use Meta’s `test_event_code` in the server payload temporarily. Remove it after validation. ## C. Use Meta Pixel Helper or browser network inspection Use the Meta Pixel Helper browser extension and/or browser developer tools to confirm: - The correct Pixel/data set is loading. - Only one base Pixel is installed. - The correct standard event fires. - `content_ids` are present and use expected IDs. - `value` is numeric. - `currency` is `USD`. - The browser Purchase uses an `eventID`. Check especially for duplicate `PageView`, `ViewContent`, `AddToCart`, and `Purchase` events. ## D. Confirm CAPI receipt In Events Manager, review the event source and diagnostics. For a server-side Purchase, confirm: - Meta received the event. - The event name is `Purchase`. - The value and currency are correct. - Product/variant IDs are present. - No payload validation errors appear. - Customer-information fields are formatted correctly where used. - The event is identified as server-side or received through CAPI. ## E. Confirm Purchase deduplication For the same test order: 1. Capture the browser `eventID`. 2. Confirm the server CAPI payload used the same string as `event_id`. 3. Review Meta event diagnostics and reporting behavior for deduplication status. 4. Confirm that one Shopify order is not represented as multiple Purchase events in the event stream. A useful test record is: | Field | Expected value | |---|---| | Shopify order ID | `1234567890` | | Browser event name | `Purchase` | | Browser event ID | `purchase_1234567890` | | CAPI event name | `Purchase` | | CAPI event ID | `purchase_1234567890` | | Purchase value | Shopify order total | | Currency | `USD` | | Content ID | Meta catalog-matching Shopify variant ID | ## F. Reconcile against Shopify orders After a short controlled test period: - Compare the count of paid Shopify orders with Purchase events received in Meta. - Compare transaction values for a sample of orders. - Check that test orders do not repeatedly fire Purchase on thank-you-page refresh. - Check that canceled, failed, or unpaid orders are not incorrectly sent as Purchases. - Check that product IDs in Meta events match catalog IDs. Meta reporting and Shopify order records will not necessarily match perfectly because the systems measure and attribute differently. The immediate objective is technically valid event delivery, correctly deduplicated purchases, and accurate order values—not identical reporting totals. ## G. Launch readiness criteria Before increasing spend, confirm: - [ ] One production Meta Pixel/data set is connected. - [ ] The Cedar & Coil domain is verified in Meta. - [ ] `ViewContent`, `AddToCart`, `InitiateCheckout`, and `Purchase` fire correctly. - [ ] Purchase sends value, currency, `content_ids`, and `contents`. - [ ] Product IDs match the Meta catalog. - [ ] Server-side Purchase delivery is active if using the native maximum-sharing setup or custom CAPI. - [ ] Browser and CAPI Purchase events deduplicate using the same event ID. - [ ] No duplicate Pixel installation exists in theme code, tag manager, and Shopify app simultaneously. - [ ] Consent behavior has been tested. - [ ] Meta Events Manager diagnostics have no unresolved critical errors. --- ## 7. Consent and compliance note Cedar & Coil should treat Meta Pixel and CAPI data sharing as a privacy, consent, and data-governance implementation—not only an ad-platform setup. ### Core requirements Before enabling or expanding tracking: 1. **Use a clear privacy policy** - Explain the use of advertising and measurement technologies, including Meta. - Explain relevant data sharing and advertising purposes. 2. **Implement consent controls where required** - In jurisdictions requiring opt-in consent for advertising cookies or similar technologies, do not fire nonessential Meta browser tracking or transmit corresponding server-side advertising data before consent is obtained. - Configure Shopify’s customer privacy settings and consent banner appropriately for the markets Cedar & Coil serves. 3. **Respect opt-outs and withdrawals** - If a visitor declines advertising tracking or withdraws consent, ensure browser and server-side behavior reflects that choice. - A server-side implementation must not bypass a consent decision made in the browser. 4. **Send only necessary data** - Use data minimization. - Do not send sensitive categories of information. - Do not use tracking data to infer or target sensitive personal characteristics. 5. **Secure access** - Keep Meta access tokens in secure server-side secret storage. - Limit access to Shopify customer data and Meta Events Manager. - Review access when staff or agencies change. 6. **Document the implementation** - Record which events are sent. - Record which identifiers are sent and whether they are hashed. - Record which system owns each event: Shopify/Meta native integration, custom browser Pixel, custom CAPI service, or tag manager. - Record the consent conditions under which each event may fire. For Cedar & Coil’s initial Arc Clip Lamp campaign, the practical recommendation is: ```text Use the official Shopify Facebook & Instagram by Meta sales channel, connect one production Pixel/data set and catalog, enable the highest data-sharing level that is appropriate under Cedar & Coil’s consent and privacy setup, validate browser and server event receipt, and do not add parallel custom Purchase tracking unless it is intentionally replacing the managed implementation. ```
Score · attempt 3 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 browser Pixel plus server-side CAPI with a comparison table explaining why both are needed under privacy limits.
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 sketches for ViewContent, AddToCart, InitiateCheckout, and Purchase, each with value, currency, and content_ids (plus order_id 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 Node.js example includes event_name, event_time, event_id, action_source: 'website', and a user_data block with hashed fields.
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.B instructs using Meta Events Manager's Test Events tool, and Section 6.E explicitly walks through confirming browser/server event_id match and no duplicate Purchase events.
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 the Shopify order/webhook is the source of truth for Purchase ('The server-side order event should be the source of truth for whether the order is actually paid') while ViewContent/AddToCart/InitiateCheckout fire via the browser Pixel.
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 attribution-recovery percentages are promised anywhere, and Section 7 states consent must gate whether nonessential tracking/data can be sent at all.
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 'send the same event_name' and 'the same event_id' so 'Meta can then treat those records as one Purchase event,' with matching browser eventID and CAPI event_id examples.
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 as `purchase_{order_id}` and the guide mandates 'Idempotency protection so the same order does not create duplicate CAPI events,' implying stability across retries rather than a fresh random value 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: Math.floor(Date.now() / 1000)`, which is the current send time rather than the order's occurrence timestamp, and no guidance instructs preserving the original timestamp 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 hashing section and sha256() function explicitly trim and lowercase values (e.g., email) before SHA-256 hashing prior to 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).
✓Section 5 gives a decisive recommendation ('Start with the official Shopify Meta integration for Cedar & Coil') with a concrete numbered setup checklist (steps 1-8) for a small DTC store.

GPT-5.6 Sol medium 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.21 · 112.1s · 7.0k tok
# Cedar & Coil: Shopify-to-Meta Conversion Tracking Guide ## 1. Recommended architecture Use both: 1. **Browser-side Meta Pixel** 2. **Server-side Meta Conversions API (CAPI)** 3. **A shared event ID for deduplication** ```text Customer browser ── Meta Pixel ───────────────► Meta │ ▲ └── Shopify checkout/order ── CAPI ────────┘ Same event_name + event_id ``` ### Why both are needed **The Pixel provides:** - Immediate browser interaction signals - Browser identifiers such as `_fbp` and `_fbc` - Page URL, browser context, and click-session information - Events such as product views and cart additions that may not reach Shopify’s backend **CAPI provides:** - Events sent from Shopify or a controlled server rather than relying solely on browser JavaScript - More reliable Purchase delivery when browser scripts are blocked, pages close quickly, or cookies are restricted - The ability to include normalized and hashed customer matching fields - Better control over retries, logging, and webhook processing CAPI is not a way to circumvent consent requirements, and it does not guarantee that every conversion will be attributed. It gives Meta a second, more resilient event-delivery path. ### Important implementation rule Do not install several independent Pixel/CAPI integrations. For example, do not run the native Meta Shopify channel and a separate manual Purchase integration unless the overlap is intentionally designed and deduplicated. Accidental duplication can inflate Purchase counts. --- ## 2. Standard events and parameters Use Meta’s standard event names exactly as shown. For Cedar & Coil, the Arc Clip Lamp is currently priced at **$68**, so browser examples may use `68.00` and `USD`. In production, always send the actual storefront currency and transaction values rather than hard-coding them. The `content_ids` values should exactly match the item IDs used in Cedar & Coil’s Meta catalog. Depending on the Shopify catalog configuration, this may be a Shopify variant ID, product ID, or a prefixed retailer ID. Confirm the value in Commerce Manager rather than assuming its format. ### ViewContent Fire when the Arc Clip Lamp product detail page is meaningfully viewed. ```json { "content_ids": ["CATALOG_ITEM_ID"], "content_type": "product", "content_name": "Arc Clip Lamp", "content_category": "Lighting", "value": 68.00, "currency": "USD" } ``` Use the displayed product or selected variant price. ### AddToCart Fire each time a customer adds the product to the cart. ```json { "content_ids": ["CATALOG_ITEM_ID"], "content_type": "product", "contents": [ { "id": "CATALOG_ITEM_ID", "quantity": 1, "item_price": 68.00 } ], "value": 68.00, "currency": "USD" } ``` For multiple units, `value` should reflect price multiplied by quantity. Do not reuse the same event ID for separate, legitimate AddToCart actions. Each user action needs its own event ID, with that ID shared only between the browser and server copies of that action. ### InitiateCheckout Fire when the customer enters the checkout flow, not merely when the cart drawer opens. ```json { "content_ids": ["CATALOG_ITEM_ID"], "content_type": "product", "contents": [ { "id": "CATALOG_ITEM_ID", "quantity": 1, "item_price": 68.00 } ], "num_items": 1, "value": 68.00, "currency": "USD" } ``` Use a consistent definition for `value`, normally the checkout subtotal before shipping and tax. If another definition is selected, document and apply it consistently. ### Purchase Fire once for a completed, successful purchase according to the store’s payment semantics. ```json { "content_ids": ["CATALOG_ITEM_ID"], "content_type": "product", "contents": [ { "id": "CATALOG_ITEM_ID", "quantity": 1, "item_price": 68.00 } ], "num_items": 1, "value": 68.00, "currency": "USD" } ``` Required operational rules: - `content_ids` must match the Meta catalog IDs. - `currency` must be a valid three-letter code such as `USD`. - `value` must be numeric, not `"$68.00"`. - For multi-item orders, include every purchased catalog item. - Decide whether Purchase value includes discounts, tax, and shipping. A common implementation uses the final charged order total, but consistency across Pixel, CAPI, and reporting is more important than the particular convention. - Use the actual presentment currency for international orders. - Do not fire Purchase for a failed payment. Server CAPI events also need top-level fields such as: - `event_name` - `event_time` - `event_id` - `action_source: "website"` - `user_data` - `custom_data` --- ## 3. Exactly how Pixel/CAPI deduplication works Meta deduplicates browser and server copies of an event when both have: 1. The exact same `event_name` 2. The exact same `event_id` For example, a browser Purchase might be sent as: ```html <script> const eventId = "purchase_cedar-and-coil_123456789"; fbq( "track", "Purchase", { value: 68.00, currency: "USD", content_ids: ["CATALOG_ITEM_ID"], content_type: "product" }, { eventID: eventId } ); </script> ``` The corresponding CAPI event must contain: ```json { "event_name": "Purchase", "event_id": "purchase_cedar-and-coil_123456789" } ``` Note the API naming difference: - Pixel: `eventID` - CAPI: `event_id` ### Event ID design For Purchase, use a deterministic, non-personal identifier based on the Shopify order ID: ```text purchase_{shop_namespace}_{shopify_order_id} ``` Example: ```text purchase_cedar-and-coil_123456789 ``` Namespacing prevents collisions if more than one store uses the same Meta data source. Do not place email addresses, phone numbers, or other personal information in the event ID. For interaction events such as AddToCart, create a UUID for each action. The browser should send that UUID to both Meta Pixel and the endpoint responsible for the server copy. ### What does not deduplicate events These do not replace a shared event ID: - Matching order value - Matching timestamps - Matching email address - Matching `external_id` - Matching browser URL - Using the Shopify order number only in `custom_data` If the Pixel creates one random ID and the server creates a different ID, Meta sees two events. Send the two copies promptly. Do not rely on deduplication for a browser event sent now and a server event delivered days later. Also make webhook processing idempotent so a Shopify retry does not create repeated CAPI events. --- ## 4. Preparing customer information for server-side events CAPI customer matching fields belong in `user_data`. Where available and legally permitted, useful fields include: - Email: `em` - Phone: `ph` - First name: `fn` - Last name: `ln` - City: `ct` - State or region: `st` - Postal code: `zp` - Country: `country` - Stable customer identifier: `external_id` - Meta browser ID: `fbp` - Meta click ID: `fbc` - Browser IP: `client_ip_address` - Browser user agent: `client_user_agent` ### Normalize, then hash For fields Meta expects to be hashed: 1. Convert to the expected canonical format. 2. Encode as UTF-8. 3. Hash with SHA-256. 4. Send the lowercase hexadecimal hash. Examples: - Email: trim whitespace and lowercase it. - Phone: normalize to a complete international number and remove punctuation. - Names: trim and lowercase according to Meta’s normalization rules. - Country: use the lowercase two-letter country code. - External ID: use a stable internal customer ID, namespace it if necessary, then hash it. Use Meta’s current Business SDK or normalization documentation for international names and addresses rather than creating ad hoc rules. ### Do not hash these fields Send the following in their expected raw formats: - `client_ip_address` - `client_user_agent` - `fbp` - `fbc` Do not invent an `fbc` value. Capture it only when a real Meta click identifier is present. In a custom Shopify build, first-party identifiers may need to be carried through cart attributes, checkout context, or another approved storage mechanism so they are available when the Purchase webhook arrives. ### Additional safeguards - Omit empty fields rather than hashing empty strings. - Never expose the CAPI access token in browser code. - Treat hashed customer data as personal data; hashing is not anonymization. - Limit logs so they do not contain raw customer details or access tokens. --- ## 5. Concrete Shopify setup ## Option A: Native Facebook & Instagram by Meta sales channel For a small DTC store, this is the recommended starting point. ### Setup path 1. In **Shopify Admin**, install or open **Facebook & Instagram by Meta**. 2. Connect the correct: - Meta business portfolio - Facebook Page - Ad account - Commerce account/catalog - Meta Pixel or dataset 3. Enable product catalog synchronization. 4. Open the channel’s **customer data sharing** settings. 5. Select **Maximum** where legally permitted and consistent with Cedar & Coil’s consent configuration. - Shopify’s labels may appear as `Conservative` or `Standard`, `Enhanced`, and `Maximum`, depending on the current interface. - Maximum is the level intended to use server-side Conversions API in addition to browser collection. 6. Confirm that the selected Pixel/dataset is the same one attached to the ad account. 7. Configure Shopify’s customer privacy and consent settings. 8. Remove or disable obsolete manually installed Meta Pixel scripts that would send the same events again. 9. In Meta Events Manager, verify the store domain and complete any requested web-event configuration. ### Advantages - Fastest supported setup - Pixel and CAPI are configured together - Deduplication is managed by the partner integration - Product catalog IDs are more likely to remain aligned - Less custom code and less webhook maintenance - Shopify and Meta update the integration as their checkout and API behavior changes ### Limitations - Less control over payload construction and event timing - Harder to add internal diagnostics or specialized business rules - Event ID and customer-data transport are largely opaque - Troubleshooting depends partly on Shopify and Meta partner diagnostics For Cedar & Coil’s current single-product, small-DTC use case, these tradeoffs favor the native channel. --- ## Option B: Custom Pixel and CAPI implementation Use a custom implementation only when Cedar & Coil needs requirements the native integration cannot support. A custom implementation typically needs: 1. A Shopify Web Pixel or approved customer-events implementation for browser events 2. An application backend 3. Shopify webhook subscriptions, such as an order-paid event 4. Meta CAPI credentials stored only on the server 5. A mechanism to share event IDs between browser and server 6. Capture and transport of permitted `_fbp`, `_fbc`, IP, and user-agent data 7. Catalog ID mapping 8. HMAC verification, retries, idempotency, monitoring, and token rotation 9. Appropriate Shopify access to protected customer data Be careful with asynchronous payment methods. The browser may reach a checkout-completed state before payment is confirmed. Define Purchase consistently and use a paid-order signal for the server event where appropriate. ### Server-side Purchase request sketch The following Node.js sketch assumes: - The Shopify webhook signature has already been verified. - `order` is a trusted Shopify order payload. - Customer data was collected and transferred with valid consent. - Catalog IDs have been mapped correctly. - The same event ID is used in the browser Purchase event. ```js import crypto from "node:crypto"; const META_API_VERSION = process.env.META_API_VERSION; const META_DATASET_ID = process.env.META_DATASET_ID; // Pixel/dataset ID const META_ACCESS_TOKEN = process.env.META_ACCESS_TOKEN; function sha256(value) { return crypto .createHash("sha256") .update(value, "utf8") .digest("hex"); } function normalizedEmail(value) { return value?.trim().toLowerCase(); } function normalizedPhone(value) { // Production code should first normalize to a complete // international number, then remove non-digits. return value?.replace(/\D/g, ""); } function hashedArray(value) { return value ? [sha256(value)] : undefined; } function withoutUndefined(object) { return Object.fromEntries( Object.entries(object).filter(([, value]) => value !== undefined) ); } export async function sendPurchaseToMeta(order, attribution = {}) { const eventId = `purchase_cedar-and-coil_${order.id}`; const contentIds = order.line_items.map(line => { // Replace this with the exact retailer ID found in Meta Commerce Manager. return String(line.meta_catalog_id ?? line.variant_id); }); const contents = order.line_items.map((line, index) => ({ id: contentIds[index], quantity: Number(line.quantity), item_price: Number(line.price) })); const userData = withoutUndefined({ em: hashedArray(normalizedEmail(order.email)), ph: hashedArray(normalizedPhone(order.phone)), fn: hashedArray(order.billing_address?.first_name?.trim().toLowerCase()), ln: hashedArray(order.billing_address?.last_name?.trim().toLowerCase()), country: hashedArray( order.billing_address?.country_code?.trim().toLowerCase() ), external_id: hashedArray( order.customer?.id ? `shopify_customer_${order.customer.id}` : undefined ), // These fields must not be SHA-256 hashed. client_ip_address: attribution.clientIp ?? order.browser_ip ?? undefined, client_user_agent: attribution.userAgent ?? order.client_details?.user_agent ?? undefined, fbp: attribution.fbp, fbc: attribution.fbc }); const event = { event_name: "Purchase", event_time: Math.floor( new Date(order.processed_at ?? order.created_at).getTime() / 1000 ), event_id: eventId, action_source: "website", user_data: userData, custom_data: { currency: order.currency, value: Number(order.current_total_price ?? order.total_price), content_ids: contentIds, content_type: "product", contents, num_items: contents.reduce( (sum, item) => sum + item.quantity, 0 ) } }; const response = await fetch( `https://graph.facebook.com/${META_API_VERSION}/${META_DATASET_ID}/events`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ data: [event], access_token: META_ACCESS_TOKEN // During testing only: // test_event_code: process.env.META_TEST_EVENT_CODE }) } ); const result = await response.json(); if (!response.ok) { throw new Error(`Meta CAPI error: ${JSON.stringify(result)}`); } return { eventId, result }; } ``` Production code should additionally: - Verify Shopify webhook HMAC before processing the body. - Record the Shopify webhook ID and reject already-processed retries. - Retry transient Meta failures with bounded exponential backoff. - Avoid logging raw customer information or access tokens. - Strip token-bearing checkout URLs before using `event_source_url`. - Store Meta credentials in a secret manager. - Use the currently supported Meta Graph API version. - Add `test_event_code` only during Events Manager testing. --- ## 6. Validate end to end before scaling spend ### A. Audit the installation Confirm that: - Only the intended Meta integration is active. - The Pixel/dataset ID is correct. - The ad account uses that same data source. - The Shopify product feed points to the intended Meta catalog. - Arc Clip Lamp content IDs match the catalog’s retailer IDs. - An old theme script, tag manager tag, or previous app is not sending duplicate events. ### B. Use Meta Events Manager Test Events Run a complete test journey: 1. Open the Arc Clip Lamp product page. 2. Confirm `ViewContent`. 3. Add the lamp to the cart. 4. Confirm `AddToCart`. 5. Enter checkout. 6. Confirm `InitiateCheckout`. 7. Place a test order. 8. Confirm `Purchase`. For custom CAPI requests, include the temporary `test_event_code` supplied by Events Manager. Remove it after testing. ### C. Inspect each event Verify: - Correct standard event name - Valid Unix event time - Correct `value` and `currency` - Correct `content_ids` - Correct quantity and item price - `action_source` is `website` - Browser and server Purchase copies use the same event ID - Browser events contain useful URL/browser context - Server events contain permitted matching fields - No raw email or phone appears where hashes are expected Meta Pixel Helper can help inspect browser events, although Shopify checkout sandboxing and privacy controls may limit what a browser extension can see. Events Manager should be the final source for delivery status. ### D. Verify deduplication In Events Manager, the Purchase should appear as a browser/server pair that is deduplicated into one logical event—not two Purchases. If it is counted twice, inspect: - `eventID` on the Pixel event - `event_id` on the CAPI event - Exact capitalization of `Purchase` - Whether a second Pixel or Shopify app is firing - Whether the native channel and custom code are both active If only the browser event appears, inspect the CAPI response, token, data source ID, and webhook logs. If only the server event appears, inspect consent state, browser script loading, and checkout event configuration. ### E. Test privacy and browser scenarios Test at least: - Consent accepted - Consent declined where applicable - Safari or another privacy-restrictive browser - A browser with content blocking - A direct visit without a Meta click - A test visit containing a legitimate Meta click identifier - Returning-customer checkout - Discounted order - Multi-quantity order - Failed or abandoned checkout - Delayed-payment order, if supported Declined-consent behavior should match the store’s legal configuration; the absence of an event may be correct. ### F. Reconcile against Shopify Before increasing spend, compare Meta’s received Purchase events with Shopify paid orders for several test transactions and a limited live observation period. Check: - Number of paid orders versus unique Purchase event IDs - Revenue definitions, including discounts, tax, and shipping - Currency handling - Duplicate webhook deliveries - Missing or unmatched catalog IDs - Meta Events Manager Diagnostics Meta-attributed conversions will not necessarily equal all Shopify orders because attribution rules and identity matching differ. The implementation goal is accurate delivery of eligible events, not forced agreement between every reporting system. --- ## 7. Consent and compliance Pixel and CAPI collection must follow Cedar & Coil’s applicable privacy, advertising, and cookie obligations. - Configure Shopify’s customer privacy settings and consent banner for relevant regions. - Do not treat CAPI as a workaround for a customer’s tracking choice. - Gate browser and server-side advertising events where consent is required. - Pass only data Cedar & Coil is authorized to use for advertising and measurement. - Update the privacy notice to describe Meta advertising, browser collection, server-side sharing, purposes, and user choices. - Honor deletion, access, opt-out, and other applicable data-subject requests. - Restrict access to customer data and Meta credentials. - Minimize retention and redact sensitive logs. - Review Shopify’s and Meta’s current terms, data-processing provisions, and regional controls. - Remember that SHA-256 hashing reduces direct exposure but does not make customer information anonymous. For the initial implementation, use the native Meta sales channel with the highest legally appropriate data-sharing setting, validate deduplication through test orders, and move to a custom implementation only if Cedar & Coil develops a clear requirement the native integration cannot meet.
Score · attempt 1 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 explicitly recommends Pixel + CAPI with a shared event ID and explains what each provides (browser identifiers vs. resilient server delivery) as the reason 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 gives JSON examples for ViewContent, AddToCart, InitiateCheckout, and Purchase, with Purchase explicitly requiring content_ids, currency, and numeric value.
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 sendPurchaseToMeta function builds an event object with event_name, event_time, event_id, 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 6B/6D instruct using Meta Events Manager Test Events and explicitly checking that the Purchase 'browser/server pair' is deduplicated into one event, not two.
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).
✗Only Purchase is clearly tied to the Shopify order-paid webhook as the source of truth (not the thank-you page); ViewContent, AddToCart, and InitiateCheckout are never explicitly labeled as browser-only vs. server-fired, leaving their firing source ambiguous.
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 guide states CAPI 'does not guarantee that every conversion will be attributed' and repeatedly ties event sending to consent and regional legal permission (Section 4 and Section 7).
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 deduplication requires 'the exact same event_name' and 'the exact same event_id' on both Pixel and CAPI copies, with concrete matching examples.
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 as purchase_{shop_namespace}_{shopify_order_id}, reused unchanged, and the guide explicitly requires idempotent webhook processing so retries don't create new events.
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.
✓event_time is computed as Math.floor(new Date(order.processed_at ?? order.created_at).getTime()/1000), using the order's actual timestamp rather than the current send time.
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.
✓normalizedEmail trims and lowercases the email before sha256() hashing it for the em field 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 explicitly recommends 'Option A: Native Facebook & Instagram by Meta sales channel... For a small DTC store, this is the recommended starting point' with a numbered 9-step setup path.
✓ Attempt 2
Answer · attempt 2 the model's full response$0.19 · 99.2s · 6.3k tok
# Cedar & Coil Shopify-to-Meta Conversion Tracking Guide ## 1. Recommended architecture: Meta Pixel + Conversions API Use both of Meta’s website event channels: 1. **Browser-side Meta Pixel** - Runs in the shopper’s browser. - Captures page and interaction events quickly. - Can read browser identifiers such as `_fbp` and `_fbc`. - Is vulnerable to ad blockers, browser privacy controls, script failures, and consent restrictions. 2. **Server-side Conversions API, or CAPI** - Sends events from Shopify or a secure server directly to Meta. - Is more reliable for completed transactions because it does not depend on the thank-you page script running. - Can include authoritative order values and line items from Shopify. - Must not be used to bypass consent or privacy choices. Send important events through both channels where feasible, especially `Purchase`. Use **deduplication** so Meta treats the browser and server copies as one conversion rather than two. This architecture improves measurement resilience, but it does not guarantee that every order will be attributable to an ad. Tracking, matching, and ad attribution are separate processes. --- ## 2. Standard events and parameters Use the same product ID convention across Shopify, the Meta catalog, Pixel, and CAPI. If the native Meta channel creates catalog IDs for you, use the IDs it supplies rather than assuming a raw Shopify product or variant ID. Amounts should reflect the actual Shopify transaction after applicable discounts. Decide consistently whether `Purchase.value` includes shipping and tax; using Shopify’s final order total is the simplest approach. ### `ViewContent` Fire when a visitor views the Arc Clip Lamp product page. Recommended parameters: ```json { "content_ids": ["CATALOG_ITEM_ID"], "content_type": "product", "content_name": "Arc Clip Lamp", "value": 68.00, "currency": "USD" } ``` Notes: - `content_ids` must match the item ID in Meta’s catalog. - Use the shopper’s storefront currency if the store supports multiple currencies. - If variants have separate catalog IDs, send the selected variant’s ID. ### `AddToCart` Fire once for each deliberate add-to-cart action. ```json { "content_ids": ["CATALOG_ITEM_ID"], "content_type": "product", "contents": [ { "id": "CATALOG_ITEM_ID", "quantity": 1, "item_price": 68.00 } ], "value": 68.00, "currency": "USD" } ``` For multiple items, calculate `value` as the sum of item price multiplied by quantity. ### `InitiateCheckout` Fire when the shopper begins Shopify checkout, not merely when viewing the cart. ```json { "content_ids": ["CATALOG_ITEM_ID"], "content_type": "product", "contents": [ { "id": "CATALOG_ITEM_ID", "quantity": 1, "item_price": 68.00 } ], "num_items": 1, "value": 68.00, "currency": "USD" } ``` The event should represent the checkout contents and value at that moment. ### `Purchase` Fire only when the store’s chosen purchase condition has occurred—normally a completed or paid Shopify order. Do not fire it merely because a checkout was created. ```json { "content_ids": ["CATALOG_ITEM_ID"], "content_type": "product", "contents": [ { "id": "CATALOG_ITEM_ID", "quantity": 1, "item_price": 68.00 } ], "num_items": 1, "value": 68.00, "currency": "USD", "order_id": "SHOPIFY_ORDER_ID" } ``` Key requirements: - `value` must be numeric, not `"$68.00"`. - `currency` should be the ISO 4217 code, such as `USD`. - `content_ids` must be present and must match the Meta catalog. - For real orders, use the actual order value rather than Cedar & Coil’s standard list price. - If an order contains multiple products or variants, include every catalog item in `content_ids` and `contents`. For CAPI, also send: - `event_name` - `event_time` - `event_id` - `action_source: "website"` - `user_data` - `event_source_url` when genuinely available - `custom_data` containing the commerce parameters above --- ## 3. Exactly how Pixel/CAPI deduplication works For each action sent through both Pixel and CAPI, create one unique event ID and use it in both copies. A browser Purchase might be sent as: ```javascript const purchaseEventId = `purchase_${shopifyOrderId}`; fbq( "track", "Purchase", { value: 68.00, currency: "USD", content_ids: ["CATALOG_ITEM_ID"], content_type: "product" }, { eventID: purchaseEventId } ); ``` The server copy must use the same event name and ID: ```json { "event_name": "Purchase", "event_id": "purchase_1234567890" } ``` Meta deduplicates using the pair: - The same `event_name`, including capitalization - The same `event_id` Therefore: - Browser `Purchase` + server `Purchase` with the same ID → one logical event. - Same order but different IDs → likely counted as two events. - Same ID but different event names → not a valid deduplication pair. - Missing `eventID` in the Pixel call → no reliable deduplication. - `event_id` belongs at the top level of the CAPI event, not inside `custom_data`. Recommended ID patterns: - Purchase: `purchase_{stable_shopify_order_id}` - Add to cart: a new UUID for each add action - Checkout: `checkout_{stable_checkout_token_or_id}` Additional rules: 1. **Reuse the same ID for retries.** If a webhook or API request is retried, do not generate a new Purchase ID. 2. **Do not reuse an ID across separate actions.** 3. **Keep event parameters aligned.** Browser and server copies should have the same currency, value, catalog IDs, and order definition. 4. **Preserve the original event time on retries.** 5. **Store the ID when necessary.** A custom build may need to persist the browser-generated ID with the checkout or order so the webhook can recover it. The native Shopify Meta integration manages this coordination. In a custom implementation, Cedar & Coil is responsible for it. --- ## 4. Preparing customer information for server-side events CAPI’s `user_data` helps Meta match an event to an account. Send only data that Cedar & Coil is permitted to process and transmit. ### Fields that must be normalized and SHA-256 hashed Common fields include: - `em`: email - `ph`: phone - `fn`: first name - `ln`: last name - `ct`: city - `st`: state or region - `zp`: postal code - `country`: country code - `external_id`: Cedar & Coil’s stable customer ID, if used General preparation: 1. Convert text to lowercase where applicable. 2. Trim leading and trailing whitespace. 3. Normalize according to Meta’s field-specific rules. 4. SHA-256 hash the normalized value. 5. Send each hashed value as a lowercase hexadecimal string. Examples: - Email: trim and lowercase before hashing. - Phone: normalize to country code plus digits before hashing. - Country: use a lowercase two-letter code such as `us`. - Do not hash blank, null, placeholder, or obviously invalid data. ### Fields that should not be hashed Send these in their expected raw formats: - `fbp` - `fbc` - `client_ip_address` - `client_user_agent` Important cautions: - Do not use the Shopify webhook server’s IP address as the customer IP. - Only send the customer IP or user agent if it was legitimately captured from the customer’s session. - `_fbc` generally exists only when there is a Meta click identifier. Do not fabricate it. - A custom implementation must securely associate browser identifiers with the later Shopify order. The native integration handles much of this work. - Never place raw email, phone, or other personal data in `custom_data`, URLs, event IDs, or logs. Hashing is a transmission requirement, not anonymization and not a substitute for consent or another lawful basis. --- ## 5. Shopify setup path ### Option A: Native Facebook & Instagram by Meta sales channel Typical setup path: 1. In **Shopify Admin**, open **Settings → Apps and sales channels**. 2. Install or open **Facebook & Instagram by Meta**. 3. Connect Cedar & Coil’s: - Meta Business Portfolio - Facebook Page - Ad account - Meta Pixel/data source - Commerce account and catalog, where applicable 4. In the channel’s data-sharing settings, choose **Maximum** if appropriate for Cedar & Coil’s consent model and operating regions. 5. Confirm the integration is using the intended Pixel and catalog. 6. Sync the Arc Clip Lamp to the catalog. 7. Check the catalog item ID and confirm that event `content_ids` match it. 8. Configure Shopify’s customer privacy and cookie-banner settings before enabling marketing data collection in regions requiring consent. 9. Remove or disable old Meta Pixel code, duplicate tag-manager tags, or another Meta app that sends the same events. “Maximum” data sharing generally enables the browser Pixel plus server-side data sharing through CAPI. Shopify and Meta can change labels or menu locations, so verify the resulting event sources in Meta Events Manager. #### Recommendation for Cedar & Coil For a small DTC store selling the Arc Clip Lamp, use the **native Facebook & Instagram by Meta channel with the highest appropriate data-sharing setting**. Reasons: - Lower implementation and maintenance burden - Built-in coordination between browser and server events - Catalog ID consistency - Less risk of duplicate Purchases - Automatic adaptation to Shopify checkout changes - Fewer secrets, webhooks, and customer-identifier pipelines to maintain Do not install the native integration and then add a separate custom Pixel/CAPI implementation for the same events unless there is a deliberate ownership and deduplication plan. ### Option B: Custom implementation A custom build is appropriate only when Cedar & Coil needs requirements the native channel cannot meet, such as: - A controlled first-party event pipeline - Custom event governance or routing - Complex multi-store catalog mappings - Additional server-side destinations - Detailed internal observability A custom implementation typically uses: - Shopify Customer Events or a custom pixel for browser events - An authenticated Shopify `orders/paid` webhook for server Purchase events - Secure storage for Meta access tokens - A database or idempotency store for webhook retries - A method to carry `event_id`, `_fbp`, `_fbc`, consent state, and user-agent information from browser session to order - HMAC verification of every Shopify webhook Avoid relying on legacy checkout theme scripts. Shopify Customer Events and checkout extensibility are the supported direction. ### Illustrative server-side Purchase request The following Node.js sketch shows the shape of a custom CAPI request. It omits webhook routing and storage code for clarity. ```javascript import crypto from "node:crypto"; const sha256 = (value) => crypto .createHash("sha256") .update(value) .digest("hex"); const normalizedEmail = (value) => value.trim().toLowerCase(); const normalizedPhone = (value) => value.replace(/[^\d]/g, ""); // Ensure the country code is included. function catalogIdForLineItem(lineItem) { // Must return the exact ID used by Cedar & Coil's Meta catalog. // Do not assume this is the raw variant ID if Shopify's channel // has created a prefixed catalog ID. return String(lineItem.meta_catalog_id); } export async function sendMetaPurchase(order, attribution = {}) { const pixelId = process.env.META_PIXEL_ID; const accessToken = process.env.META_CAPI_ACCESS_TOKEN; const graphVersion = process.env.META_GRAPH_VERSION; if (!pixelId || !accessToken || !graphVersion) { throw new Error("Missing Meta CAPI configuration"); } const eventId = `purchase_${order.id}`; const userData = {}; if (order.email) { userData.em = [sha256(normalizedEmail(order.email))]; } if (order.phone) { userData.ph = [sha256(normalizedPhone(order.phone))]; } if (order.customer?.id) { userData.external_id = [ sha256(String(order.customer.id).trim().toLowerCase()) ]; } // These fields are not hashed. Include only when they were captured // from the customer's browser session and their use is permitted. if (attribution.fbp) userData.fbp = attribution.fbp; if (attribution.fbc) userData.fbc = attribution.fbc; if (attribution.clientIp) { userData.client_ip_address = attribution.clientIp; } if (attribution.userAgent) { userData.client_user_agent = attribution.userAgent; } const contents = order.line_items.map((item) => ({ id: catalogIdForLineItem(item), quantity: Number(item.quantity), item_price: Number(item.price) })); const contentIds = contents.map((item) => item.id); const numItems = contents.reduce( (sum, item) => sum + item.quantity, 0 ); const eventTime = Math.floor( new Date(order.processed_at || order.created_at).getTime() / 1000 ); const body = { data: [ { event_name: "Purchase", event_time: eventTime, event_id: eventId, action_source: "website", user_data: userData, custom_data: { currency: order.currency, value: Number(order.total_price), content_type: "product", content_ids: contentIds, contents, num_items: numItems, order_id: String(order.id) } } ] }; // Add this only while testing with a code from Meta Events Manager: if (process.env.META_TEST_EVENT_CODE) { body.test_event_code = process.env.META_TEST_EVENT_CODE; } const endpoint = `https://graph.facebook.com/v${graphVersion}/` + `${pixelId}/events?access_token=${encodeURIComponent(accessToken)}`; const response = await fetch(endpoint, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(body) }); const result = await response.json(); if (!response.ok || result.events_received !== 1) { throw new Error(`Meta CAPI error: ${JSON.stringify(result)}`); } return { eventId, result }; } ``` Production requirements not shown in the sketch: - Verify Shopify webhook HMAC before reading the payload. - Keep the CAPI access token server-side and out of Shopify theme code. - Record processed Shopify webhook IDs or order IDs for idempotency. - Retry transient failures with the same `event_id` and original `event_time`. - Use Meta’s current supported Graph API version. - Store only the minimum necessary attribution data. - Avoid logging request bodies containing customer information. - Ensure the browser Purchase, if sent, uses the same `purchase_{order.id}` ID. --- ## 6. End-to-end validation before scaling spend ### A. Audit for duplicate installations Check for: - A hard-coded `fbq()` base script in the theme - Google Tag Manager Meta tags - Shopify custom pixels - The native Meta sales channel - Third-party tracking or upsell apps - Legacy order-status-page scripts There should be one clearly owned implementation for each event. ### B. Validate browser events Use Meta Pixel Helper and browser developer tools to confirm: 1. `ViewContent` fires once on the Arc Clip Lamp product page. 2. `AddToCart` fires once per add action. 3. `InitiateCheckout` fires when checkout begins. 4. `Purchase` fires only after a completed order. 5. Event values are numeric. 6. Currency is correct. 7. `content_ids` match the catalog exactly. 8. Browser events include `eventID` when a server duplicate will also be sent. Test normal navigation, page refreshes, quantity changes, and back-button behavior. ### C. Validate server events In Meta Events Manager: 1. Open the Pixel/data source. 2. Use **Test Events**. 3. For a custom implementation, add the supplied `test_event_code` to CAPI requests. 4. Place a Shopify test order. 5. Confirm the API response reports the expected `events_received`. 6. Review Events Manager diagnostics for rejected or malformed parameters. Remove the test event code before production use. ### D. Confirm Purchase deduplication For one test order, verify that Meta receives: - One browser `Purchase` - One server `Purchase` - The same `event_name` - The same `event_id` - Matching value and currency - Matching catalog item IDs Events Manager may display both source records while showing that the pair was deduplicated. The resulting reporting should represent one logical Purchase, not two. Repeat the test with: - A direct visit - A Meta-click test where `_fbc` may be available - Safari or another privacy-restrictive browser - A browser with content blocking - Consent granted - Consent denied, where applicable - A discounted order - An order with quantity greater than one - A failed or pending payment ### E. Check data quality Review: - Event Match Quality - Pixel and CAPI coverage - Deduplication diagnostics - Missing currency or value warnings - Invalid or unmatched catalog IDs - Delayed events - Duplicate Purchase warnings Event Match Quality is a diagnostic, not a reason to collect additional customer data without authorization. ### F. Reconcile against Shopify Before increasing spend, compare Meta’s received Purchase events with Shopify’s paid orders for the same period. Account for: - Consent choices - Ad blockers and browser restrictions - Test orders - Payment timing - Time zones - Cancellations - Delayed webhooks - Meta’s attribution rules Use this reconciliation to detect broken or duplicate tracking. Do not expect Shopify order totals and Meta-attributed conversions to be identical. --- ## 7. Consent and compliance CAPI is not a method for bypassing browser privacy controls or a shopper’s consent choice. Cedar & Coil should: - Configure Shopify’s customer privacy settings and consent banner for applicable regions. - Prevent non-essential Meta browser events from firing before required consent. - Pass or enforce the same consent state in the server-side pipeline. - Honor withdrawal of consent, applicable opt-outs, and legally recognized privacy signals. - Update the privacy notice to describe Meta advertising and server-side event sharing. - Execute applicable data-processing terms with Shopify and Meta. - Restrict access to Meta tokens and event logs. - Apply retention limits to customer and attribution data. - Never send sensitive information, payment-card data, passwords, or unnecessary free-form fields. - Avoid placing personal information in URLs, `event_id`, `order_id`, or event names. - Review requirements with qualified privacy counsel for the regions in which the store operates. For Cedar & Coil’s current size, the native Meta sales channel plus correctly configured Shopify consent controls is the most practical starting point. A custom implementation should be adopted only when the team can maintain its security, deduplication, data mapping, and compliance responsibilities.
Score · attempt 2 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.
✓The guide explicitly recommends both browser Pixel and server-side CAPI with deduplication and explains that Pixel is 'vulnerable to ad blockers, browser privacy controls...' while CAPI 'does not depend on the thank-you page script running.'
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 each with JSON parameter examples, and Purchase explicitly includes 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 sendMetaPurchase function builds a body with 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' with test_event_code, and Section 6D explicitly checks that browser and server Purchase events share event_name/event_id and are deduplicated into one logical event.
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 Purchase should come from 'an authenticated Shopify orders/paid webhook for server Purchase events' rather than the thank-you page, clarifying server-side source of truth versus browser Pixel firing for other 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.
✓The response states the architecture 'does not guarantee that every order will be attributable to an ad' without giving any percentage, and dedicates Section 7 to consent/regional constraints on what data 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.
✓It specifies 'Meta deduplicates using the pair: The same event_name... The same event_id' and shows matching purchase_{order.id} IDs used in both the fbq call and CAPI payload.
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 'Reuse the same ID for retries. If a webhook or API request is retried, do not generate a new Purchase ID' and uses eventId = `purchase_${order.id}` derived from the stable 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 eventTime from order.processed_at/created_at in Unix seconds and the guide instructs to 'Preserve 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.
✓The sketch defines normalizedEmail (trim+lowercase) and sha256 hashing, applying sha256(normalizedEmail(order.email)) before sending as em 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).
✓Section 5 gives a decisive recommendation ('use the native Facebook & Instagram by Meta channel with the highest appropriate data-sharing setting') with a concrete numbered setup path for a small DTC store.
✓ Attempt 3
Answer · attempt 3 the model's full response$0.15 · 76.2s · 5.0k tok
# Cedar & Coil: Shopify-to-Meta Conversion Tracking Guide ## 1. Recommended architecture: Meta Pixel plus Conversions API Use both of Meta’s collection paths: 1. **Browser-side Meta Pixel** - Runs in the customer’s browser. - Captures page and shopping interactions with immediate browser context. - Can read Meta identifiers such as `_fbp` and `_fbc`. - Is affected by cookie restrictions, browser privacy controls, ad blockers, network failures, and consent choices. 2. **Server-side Conversions API (CAPI)** - Sends events from Shopify or a controlled server directly to Meta. - Is more reliable for confirmed transactions because it does not depend on the browser request completing. - Can send normalized and hashed customer information to improve event matching. - Must still respect consent and applicable privacy law; it is not a way to bypass browser consent choices. ### Why both are needed The Pixel provides browser context and captures upper-funnel events such as product views and cart additions. CAPI provides a more durable path for checkout and purchase events, especially when browser requests are blocked or interrupted. Where the same conversion is sent through both paths, use **deduplication** so Meta treats the pair as one event rather than two. Recommended flow: ```text Customer browser ├─ Meta Pixel: ViewContent, AddToCart, InitiateCheckout, Purchase └─ Shopify checkout/storefront Shopify / server └─ Meta CAPI: matching events, especially Purchase └─ Same event_name + event_id as browser copy ``` Do not run overlapping native and custom implementations unless you have deliberately coordinated their event IDs. Otherwise, duplicate events are likely. --- ## 2. Standard events and parameters Use Meta’s standard event names exactly as shown. Maintain one product-ID convention across: - Shopify - Meta catalog - Pixel events - CAPI events For example, choose the Shopify product ID, variant ID, or catalog retailer ID and use it consistently. Variant IDs are often preferable when variants are represented separately in the catalog. ### `ViewContent` Fire when the Arc Clip Lamp product detail page is meaningfully viewed. Recommended parameters: ```json { "content_ids": ["SHOPIFY_VARIANT_ID"], "content_name": "Arc Clip Lamp", "content_type": "product", "contents": [ { "id": "SHOPIFY_VARIANT_ID", "quantity": 1, "item_price": 68.00 } ], "value": 68.00, "currency": "USD" } ``` Notes: - Use the storefront’s actual currency rather than hard-coding `USD` if Cedar & Coil sells in multiple currencies. - `value` should reflect the displayed product value in that currency. - Do not fire this event for every generic page view. ### `AddToCart` Fire after Shopify confirms that the item was added to the cart, not merely when the button was clicked. ```json { "content_ids": ["SHOPIFY_VARIANT_ID"], "content_name": "Arc Clip Lamp", "content_type": "product", "contents": [ { "id": "SHOPIFY_VARIANT_ID", "quantity": 1, "item_price": 68.00 } ], "value": 68.00, "currency": "USD" } ``` For multiple units, use the actual quantity and extended cart value. ### `InitiateCheckout` Fire when the shopper successfully begins checkout. ```json { "content_ids": ["SHOPIFY_VARIANT_ID"], "content_type": "product", "contents": [ { "id": "SHOPIFY_VARIANT_ID", "quantity": 1, "item_price": 68.00 } ], "num_items": 1, "value": 68.00, "currency": "USD" } ``` Use the checkout value that Shopify reports. Decide consistently whether this value includes discounts, shipping, and tax. For optimization and reporting, it is usually best to use the same value basis as the eventual `Purchase` event where possible. ### `Purchase` Fire only after the order reaches the business’s chosen confirmed state—normally successful payment rather than a thank-you page view alone. Required or strongly recommended parameters: ```json { "content_ids": ["SHOPIFY_VARIANT_ID"], "content_type": "product", "contents": [ { "id": "SHOPIFY_VARIANT_ID", "quantity": 1, "item_price": 68.00 } ], "num_items": 1, "value": 68.00, "currency": "USD", "order_id": "SHOPIFY_ORDER_ID" } ``` Important: - `value` must be numeric, not `"$68.00"`. - `currency` must be an ISO 4217 code such as `USD`. - `content_ids` must identify every purchased product using the same ID format as the Meta catalog. - Use the actual order value after discounts. Establish a documented rule for tax and shipping and apply it consistently. - `order_id` is useful for auditing, but it does **not** replace `event_id` for Pixel/CAPI deduplication. --- ## 3. Exactly how Pixel/CAPI deduplication works Meta deduplicates browser and server copies when both have: 1. The same `event_name`, such as `Purchase`; and 2. The same `event_id`. For example, the browser copy might be: ```html <script> fbq( 'track', 'Purchase', { value: 68.00, currency: 'USD', content_ids: ['SHOPIFY_VARIANT_ID'], content_type: 'product' }, { eventID: 'purchase_123456789' } ); </script> ``` The server copy must then include: ```json { "event_name": "Purchase", "event_id": "purchase_123456789" } ``` Meta can recognize these as two delivery paths for one logical purchase. ### Event-ID rules - Generate one ID per logical event occurrence. - Send that exact ID through both the Pixel and CAPI. - Keep IDs unique across unrelated events. - For a purchase, a stable value derived from the Shopify order ID is appropriate: ```text purchase_<shopify-order-id> ``` - For repeatable actions such as cart additions, use a generated UUID or another unique action ID. A bare product ID is not sufficient because a customer can add the same product more than once. - If a CAPI request is retried after a timeout, reuse the original event ID. Do not generate a new one for every retry. - `event_time`, `order_id`, email, and transaction value are not substitutes for `event_id`. - Matching only on order value or customer details is not reliable deduplication. With a native Shopify/Meta integration, the integration should coordinate the browser and server event IDs. If adding any custom events, verify that they do not overlap with native events. --- ## 4. Preparing customer information for server-side delivery CAPI sends customer matching fields inside `user_data`. Direct identifiers must be normalized and SHA-256 hashed before transmission unless the particular field is explicitly meant to be sent unhashed. ### Normalization and hashing Typical preparation: - **Email (`em`)** - Trim whitespace. - Convert to lowercase. - SHA-256 hash the normalized value. - **Phone (`ph`)** - Convert to a normalized international format, including country code. - Remove spaces, punctuation, and other non-digits as required by Meta’s specification. - SHA-256 hash the result. - **First and last name (`fn`, `ln`)** - Trim and lowercase. - Remove unsupported punctuation where required. - SHA-256 hash. - **City, state, postal code, and country** - Normalize according to Meta’s formatting rules. - Use lowercase country codes where required. - SHA-256 hash. - **External ID (`external_id`)** - Use a stable internal customer identifier where available. - Do not expose a raw Shopify customer ID or another directly reusable identifier. - Normalize and SHA-256 hash it. A simple Node.js helper: ```js import crypto from "node:crypto"; function sha256(value) { if (value == null || value === "") return undefined; return crypto .createHash("sha256") .update(String(value).trim().toLowerCase(), "utf8") .digest("hex"); } ``` Do not hash fields that Meta expects in their original form: - `fbp` - `fbc` - `client_ip_address` - `client_user_agent` `fbp` and `fbc` should be copied from the relevant browser identifiers when available and permitted. Do not fabricate them. The IP address and user agent should describe the customer request, not the Shopify server or a webhook worker. Additional rules: - Omit empty fields rather than hashing an empty string. - Never put raw email addresses, names, or phone numbers in logs. - Do not send sensitive data in `event_source_url`. - Restrict access to the Pixel ID and CAPI access token. - Keep the access token in a server-side secret manager or protected environment variable, never in storefront JavaScript. - Confirm that each field is collected and used under Cedar & Coil’s consent and privacy rules. --- ## 5. Shopify implementation path ## Option A: Native Facebook & Instagram by Meta sales channel For a small direct-to-consumer Shopify store, this is the recommended starting point. Typical setup path: 1. In Shopify Admin, open **Apps and sales channels**. 2. Install or open **Facebook & Instagram by Meta**. 3. Connect the correct: - Meta Business Portfolio/business account - Facebook Page - Ad account - Meta Pixel/dataset - Product catalog 4. Configure Shopify’s customer-data-sharing setting. 5. Select the highest data-sharing level that Cedar & Coil’s consent configuration and legal basis support. Shopify’s exact labels and available options can change, so review the description shown in the current admin. 6. Confirm that the Arc Clip Lamp is synchronized to the intended Meta catalog. 7. Verify that the catalog item ID matches the `content_ids` format sent in events. 8. Complete domain verification or other business-verification steps Meta requests. 9. Check Events Manager to confirm that both browser and server event sources appear. ### Advantages - Fastest implementation. - Shopify and Meta manage much of the Pixel/CAPI coordination. - Less maintenance when Shopify checkout behavior or Meta’s API changes. - Lower risk of exposing tokens or mishandling customer data. - Typically handles browser/server deduplication without custom ID plumbing. ### Limitations - Less control over event timing, value definitions, payload contents, and diagnostics. - Custom storefronts or unusual checkout flows may need additional work. - It may be harder to inspect every transformation. - Adding custom tracking alongside it can create duplicate events. ### Recommendation Use the native Meta sales channel first for Cedar & Coil. It is the most appropriate tradeoff for a small DTC store selling the Arc Clip Lamp. Move to a custom implementation only if there is a documented requirement the native integration cannot meet, such as a headless storefront, custom event semantics, controlled first-party event infrastructure, or advanced multi-store routing. --- ## Option B: Custom Pixel and CAPI implementation A custom build generally requires: - Shopify Web Pixels or Customer Events for browser events. - A secure server endpoint or event worker. - Shopify webhooks, preferably a payment-confirmed/order-paid signal for `Purchase`. - A mechanism for coordinating browser and server event IDs. - Secure storage and rotation of the Meta access token. - Consent propagation from the storefront into the server event pipeline. - Retry handling, idempotency, logging, and monitoring. - Ongoing maintenance as Shopify and Meta APIs evolve. Do not treat an order-created webhook as automatically equivalent to a completed purchase. Orders can be unpaid, pending, test, or later canceled. Choose and document the state that represents a confirmed purchase. Also verify Shopify webhook authenticity using Shopify’s HMAC mechanism before trusting an incoming payload. ### Server-side `Purchase` request sketch This illustrative Node.js example assumes that: - The order has been validated as paid. - The webhook signature was verified. - Consent permits the event. - Product IDs match the Meta catalog. - Customer identifiers were normalized before hashing. - `META_GRAPH_VERSION`, `META_PIXEL_ID`, and `META_CAPI_TOKEN` are server-side configuration. ```js import crypto from "node:crypto"; function sha256(value) { if (value == null || String(value).trim() === "") return undefined; return crypto .createHash("sha256") .update(String(value).trim().toLowerCase(), "utf8") .digest("hex"); } function removeUndefined(object) { return Object.fromEntries( Object.entries(object).filter(([, value]) => value !== undefined) ); } export async function sendPurchaseToMeta({ order, browserContext = {} }) { const eventId = `purchase_${order.id}`; const contents = order.line_items.map((item) => ({ // This ID format must match the connected Meta catalog. id: String(item.variant_id), quantity: Number(item.quantity), item_price: Number(item.price) })); const payload = { data: [ { event_name: "Purchase", event_time: Math.floor( new Date(order.processed_at || order.created_at).getTime() / 1000 ), event_id: eventId, action_source: "website", event_source_url: browserContext.eventSourceUrl, user_data: removeUndefined({ em: sha256(order.email), ph: sha256(order.phone), fn: sha256(order.billing_address?.first_name), ln: sha256(order.billing_address?.last_name), ct: sha256(order.billing_address?.city), st: sha256(order.billing_address?.province_code), zp: sha256(order.billing_address?.zip), country: sha256(order.billing_address?.country_code), external_id: order.customer?.id ? sha256(String(order.customer.id)) : undefined, // Send these unhashed only when captured from the customer request // and allowed by the customer's consent state. fbp: browserContext.fbp, fbc: browserContext.fbc, client_ip_address: browserContext.clientIp, client_user_agent: browserContext.userAgent }), custom_data: { currency: order.currency, value: Number(order.total_price), order_id: String(order.id), content_type: "product", content_ids: contents.map((item) => item.id), contents, num_items: contents.reduce( (sum, item) => sum + item.quantity, 0 ) } } ] }; if (process.env.META_TEST_EVENT_CODE) { payload.test_event_code = process.env.META_TEST_EVENT_CODE; } const url = `https://graph.facebook.com/` + `${process.env.META_GRAPH_VERSION}/` + `${process.env.META_PIXEL_ID}/events`; const response = await fetch(url, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ ...payload, access_token: process.env.META_CAPI_TOKEN }) }); const result = await response.json(); if (!response.ok) { throw new Error( `Meta CAPI request failed: ${response.status} ${JSON.stringify(result)}` ); } return { eventId, result }; } ``` Operational requirements: - Pin a currently supported Meta Graph API version and schedule upgrades before it expires. - Avoid logging the request body or access token. - Store an internal delivery record keyed by the Shopify order ID and event ID. - Retry transient failures with backoff while preserving the same `event_id`. - Distinguish test orders from real orders. - Decide how refunds and cancellations will be represented in internal reporting; do not emit a second `Purchase` with a new ID for the same order. - If a browser `Purchase` is also sent, it must use the exact same `purchase_<order.id>` event ID. In many Shopify checkout configurations, coordinating that order-based ID with browser code is difficult. That is another reason to prefer the native integration unless Cedar & Coil has engineering support for a custom design. --- ## 6. End-to-end validation before scaling spend ### A. Validate configuration Confirm that: - The connected Pixel/dataset belongs to the intended Meta business. - The ad account is associated with the correct data source. - The Arc Clip Lamp appears in the correct catalog. - Event `content_ids` match the catalog’s item IDs exactly. - The storefront does not contain an old theme-installed Pixel in addition to the Meta sales channel. - No tag manager, app, or custom script is sending duplicate standard events. ### B. Test browser events Use a consent state in which marketing tracking is allowed, then: 1. Open the Arc Clip Lamp product page. 2. Confirm one `ViewContent`. 3. Add the lamp to the cart. 4. Confirm one `AddToCart`. 5. Begin checkout. 6. Confirm one `InitiateCheckout`. 7. Complete a Shopify test order using an approved test method. 8. Confirm one logical `Purchase`. Inspect: - Meta Events Manager’s **Test Events** tool. - Browser developer tools and network requests. - Meta Pixel Helper where useful. - Shopify’s app and customer-event diagnostics. Check event names, IDs, product IDs, values, and currencies—not merely whether an event appeared. ### C. Test CAPI independently For custom CAPI events: - Add Meta’s `test_event_code` at the top level of the request. - Confirm that the request receives a successful Graph API response. - Confirm that the event appears in Test Events as a server event. - Remove the test code from production delivery after testing. A successful API response only means Meta accepted the request. It does not prove that values, matching data, consent logic, or deduplication are correct. ### D. Validate deduplication For a test purchase, inspect both delivery paths and verify: ```text Browser: event_name = Purchase eventID = purchase_123456789 Server: event_name = Purchase event_id = purchase_123456789 ``` Confirm that Meta reports the pair as browser/server delivery for one logical event rather than two purchases. If two purchases are counted, investigate: - Different event IDs. - Missing browser `eventID`. - A theme Pixel plus the native Meta app. - A tag-manager event plus Shopify’s native event. - Multiple CAPI workers. - Retries that generate new IDs. - Both native and custom CAPI integrations sending the same order. ### E. Reconcile against Shopify Run several controlled orders covering: - One Arc Clip Lamp. - Multiple quantities. - A discount. - Shipping and tax. - A canceled or failed payment. - A refund, if refund handling is part of the reporting plan. - Multiple currencies, if supported. For each order, compare: - Shopify order ID. - Meta `event_id`. - Purchase value. - Currency. - Quantity. - `content_ids`. - Paid timestamp. - Whether browser and server copies were deduplicated. Small timing differences are expected, but unexplained extra purchases or missing confirmed orders must be resolved before increasing spend. ### F. Monitor after launch Review Events Manager regularly for: - Diagnostics warnings. - Falling event-match quality. - Missing customer fields. - Invalid currency or value formatting. - Catalog/content-ID mismatches. - Duplicate events. - Server request failures or token expiration. - Material divergence between Shopify paid orders and Meta-received purchases. Do not expect Shopify and Meta reporting to match perfectly. They use different attribution, identity, time-zone, and reporting rules. Reconcile event delivery separately from attributed conversions. --- ## 7. Consent and compliance CAPI improves server-side delivery reliability, but it does not override privacy requirements. Cedar & Coil should: - Use a consent-management setup compatible with Shopify’s Customer Privacy API. - Prevent marketing Pixel events from firing before required consent. - Propagate the customer’s consent state to the server so CAPI events are also suppressed or limited when required. - Explain Pixel/CAPI processing, advertising use, and relevant service providers in the privacy notice. - Collect and send only the customer fields needed for the documented purpose. - Apply applicable regional requirements, including opt-out or “do not sell/share” signals where relevant. - Configure Meta’s available data-processing options when required. - Establish retention and deletion rules for any first-party event logs. - Restrict access to customer data and CAPI credentials. - Avoid sending sensitive information, URL query-string PII, or unsupported custom data. - Have counsel or a qualified privacy professional review the implementation for the regions in which Cedar & Coil operates. The appropriate practical starting point is the native **Facebook & Instagram by Meta** Shopify sales channel, configured with the store’s consent controls, followed by full browser/server deduplication and order-level validation before ad spend is scaled.
Score · attempt 3 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 browser Pixel plus server-side CAPI with deduplication and explains that Pixel provides browser context while CAPI provides a durable path when browser requests are blocked.
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 covers ViewContent, AddToCart, InitiateCheckout, and Purchase with parameter blocks, and Purchase includes value, currency, and content_ids explicitly.
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 sendPurchaseToMeta function includes event_name, event_time (Unix seconds from order timestamp), event_id, action_source: 'website', and a user_data block with hashed fields.
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's Test Events tool (6.B, 6.C) and explicitly section 6.D checks that browser/server Purchase events are deduplicated into one logical event.
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 Purchase should fire 'after the order reaches the business's chosen confirmed state—normally successful payment rather than a thank-you page view alone' and recommends a payment-confirmed/order-paid webhook as the server source.
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 attribution-recovery percentages are promised anywhere, and Section 7 lays out consent/regional constraints such as suppressing events without consent and following Shopify's Customer Privacy API.
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 explicitly states Meta deduplicates when both events share the same event_name and event_id, illustrated with matching fbq eventID and server event_id.
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 'If a CAPI request is retried after a timeout, reuse the original event ID. Do not generate a new one for every retry,' and uses order.id-derived IDs (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(order.processed_at || order.created_at).getTime()/1000), using the order's occurrence timestamp rather than the current send time.
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 specifies trimming, lowercasing, and SHA-256 hashing email (and other PII fields), matching the sha256 helper function used in the code.
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).
✓Section 5 gives a clear, numbered setup path for the native Meta sales channel and explicitly recommends it as the starting point for a small DTC store like Cedar & Coil.