← Run 20261123-054124-b1c49f32
Shopify to Meta ads conversion tracking implementation
task shopify-meta-capiNov 23, 2026skill analytics

Answers & verdicts

Gemini 4 Neon medium effort

Task failed
Task the exact prompt the model was given — assignment, source material, and skill guidance
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. --- ## Skill guidance you should follow --- name: analytics description: "Set up or audit tracking — GA4, GTM, Mixpanel, Segment; tracking plans, event naming, UTM conventions, conversion and attribution debugging. Rate metrics divide matching closed windows — never full-period spend by partial-period results; a defect is observed, the symptom it would explain is a hypothesis until the data shows the mechanism." metadata: version: 2.3.2 --- # Analytics Tracking You are an expert in analytics implementation and measurement. Your goal is to help set up tracking that provides actionable insights for marketing and product decisions. ## Initial Assessment **Check for product marketing context first:** If `.agents/product-marketing.md` exists (or `.claude/product-marketing.md`, or the legacy `product-marketing-context.md` filename, in older setups), read it before asking questions. Use that context and only ask for information not already covered or specific to this task. **Apply the project's brand:** If `BRAND.md` exists, read it before asking questions and apply it to everything you produce — its voice, messaging, and audience for anything written, and its colors, typography, and logo for anything visual. Never ask for a brand fact it already answers. If it lacks something you need, name the missing fact instead of inventing one or quietly falling back to a generic default. **Use the numbers the brand has already connected:** If `INTEGRATIONS.md` has a `## Data` section, the connected sources' daily numbers are stored under `data/<source>/<property>/` (Google Analytics and Google Ads back two years, Search Console 16 months). Read them (`magister-analytics-read`) for the current numbers and the matching earlier period before you ask the user for numbers or recommend a change. Before implementing tracking, understand: 1. **Business Context** - What decisions will this data inform? What are key conversions? 2. **Current State** - What tracking exists? What tools are in use? 3. **Technical Context** - What's the tech stack? Any privacy/compliance requirements? --- ## Core Principles ### 1. Track for Decisions, Not Data - Every event should inform a decision - Avoid vanity metrics - Quality > quantity of events ### 2. Start with the Questions - What do you need to know? - What actions will you take based on this data? - Work backwards to what you need to track ### 3. Name Things Consistently - Naming conventions matter - Establish patterns before implementing - Document everything ### 4. Maintain Data Quality - Validate implementation - Monitor for issues - Clean data > more data ### 5. Compute, Don't Eyeball - Derive every total, rate, and delta from row-level data with a script or spreadsheet — never by scanning rows and summing mentally. One silently dropped row corrupts every figure downstream of it. - Cross-check each headline figure a second, independent way (a reconciliation total, a recomputation from a different grouping) before reporting it, and chase any mismatch to the exact row. - When a claim is about one segment — a single campaign, ad set, channel, or week — report that segment's own numbers. Never fold it into a neighboring group and let the group's total speak for it. ### 6. Match Observation Windows - A rate or efficiency metric divides a numerator and denominator that cover the same closed observation window. Never divide a full period's spend by a partial period's conversions or revenue — restate both over the weeks that actually have data, and say which weeks those are. - Cohort rates use only cohorts whose observation window has ended. A trial or signup still inside its window is pending, not failed — exclude it from the denominator and label it as pending rather than counting it against the rate. ### 7. Recommend Against the Stated Goal - Analysis ends in a recommendation, and the recommendation must be argued from the goal the brief states — the launch target, audience, revenue, or positioning objective — not only from what is operationally easiest. Name which stated goal each option serves and what it trades away. ### 8. Findings Are Observed, Causes Are Hypotheses - A defect is what you can point at: the link, tag, trigger, setting, or row that breaks a documented standard or correct measurement practice. Report it as a finding with its location and the standard it breaks. - The symptom a defect would explain — a dip, a gap between two tools, a conversion count that looks wrong — is a hypothesis until the data shows the mechanism. Write "consistent with" or "would explain", name what would confirm it (a date range to compare, a tag to fire in debug mode, a report to pull), and never state the cause as settled fact. - Something is clean only when it meets every documented standard. An item that is "fine subject to a note" belongs with the findings, not the clean list. The check is a matrix, item by standard, where the standards include every allowed-value list the documentation gives (the permitted `utm_source` values, the permitted mediums, the host list): a value that is well-formed but not on its list fails that standard, and the item goes to the findings. Build the matrix with a script when there are more than a handful of items; "all have https, correct hosts, lowercase values" is not a matrix. --- ## Tracking Plan Framework ### Structure ``` Event Name | Category | Properties | Trigger | Notes ---------- | -------- | ---------- | ------- | ----- ``` ### Event Types | Type | Examples | |------|----------| | Pageviews | Automatic, enhanced with metadata | | User Actions | Button clicks, form submissions, feature usage | | System Events | Signup completed, purchase, subscription changed | | Custom Conversions | Goal completions, funnel stages | **For comprehensive event lists**: See [references/event-library.md](references/event-library.md) --- ## Event Naming Conventions ### Recommended Format: Object-Action ``` signup_completed button_clicked form_submitted article_read checkout_payment_completed ``` ### Best Practices - Lowercase with underscores - Be specific: `cta_hero_clicked` vs. `button_clicked` - Include context in properties, not event name - Avoid spaces and special characters - Document decisions --- ## Essential Events ### Marketing Site | Event | Properties | |-------|------------| | cta_clicked | button_text, location | | form_submitted | form_type | | signup_completed | method, source | | demo_requested | - | ### Product/App | Event | Properties | |-------|------------| | onboarding_step_completed | step_number, step_name | | feature_used | feature_name | | purchase_completed | plan, value | | subscription_cancelled | reason | **For full event library by business type**: See [references/event-library.md](references/event-library.md) --- ## Event Properties ### Standard Properties | Category | Properties | |----------|------------| | Page | page_title, page_location, page_referrer | | User | user_id, user_type, account_id, plan_type | | Campaign | source, medium, campaign, content, term | | Product | product_id, product_name, category, price | ### Best Practices - Use consistent property names - Include relevant context - Don't duplicate automatic properties - Avoid PII in properties --- ## GA4 Implementation ### Quick Setup 1. Create GA4 property and data stream 2. Install gtag.js or GTM 3. Enable enhanced measurement 4. Configure custom events 5. Mark conversions in Admin ### Custom Event Example ```javascript gtag('event', 'signup_completed', { 'method': 'email', 'plan': 'free' }); ``` **For detailed GA4 implementation**: See [references/ga4-implementation.md](references/ga4-implementation.md) --- ## Google Tag Manager ### Container Structure | Component | Purpose | |-----------|---------| | Tags | Code that executes (GA4, pixels) | | Triggers | When tags fire (page view, click) | | Variables | Dynamic values (click text, data layer) | ### Data Layer Pattern ```javascript dataLayer.push({ 'event': 'form_submitted', 'form_name': 'contact', 'form_location': 'footer' }); ``` **For detailed GTM implementation**: See [references/gtm-implementation.md](references/gtm-implementation.md) --- ## UTM Parameter Strategy ### Standard Parameters | Parameter | Purpose | Example | |-----------|---------|---------| | utm_source | Traffic source | google, newsletter | | utm_medium | Marketing medium | cpc, email, social | | utm_campaign | Campaign name | spring_sale | | utm_content | Differentiate versions | hero_cta | | utm_term | Paid search keywords | running+shoes | ### Naming Conventions - Lowercase everything - Use underscores or hyphens consistently - Be specific but concise: `blog_footer_cta`, not `cta1` - Document all UTMs in a spreadsheet --- ## Debugging and Validation ### Testing Tools | Tool | Use For | |------|---------| | GA4 DebugView | Real-time event monitoring | | GTM Preview Mode | Test triggers before publish | | Browser Extensions | Tag Assistant, dataLayer Inspector | ### Validation Checklist - [ ] Events firing on correct triggers - [ ] Property values populating correctly - [ ] No duplicate events - [ ] Works across browsers and mobile - [ ] Conversions recorded correctly - [ ] No PII leaking ### Common Issues | Issue | Check | |-------|-------| | Events not firing | Trigger config, GTM loaded | | Wrong values | Variable path, data layer structure | | Duplicate events | Multiple containers, trigger firing twice | --- ## Privacy and Compliance ### Considerations - Cookie consent required in EU/UK/CA - No PII in analytics properties - Data retention settings - User deletion capabilities ### Implementation - Use consent mode (wait for consent) - IP anonymization - Only collect what you need - Integrate with consent management platform --- ## Output Format ### Tracking Plan Document ```markdown # [Site/Product] Tracking Plan ## Overview - Tools: GA4, GTM - Last updated: [Date] ## Events | Event Name | Description | Properties | Trigger | |------------|-------------|------------|---------| | signup_completed | User completes signup | method, plan | Success page | ## Custom Dimensions | Name | Scope | Parameter | |------|-------|-----------| | user_type | User | user_type | ## Conversions | Conversion | Event | Counting | |------------|-------|----------| | Signup | signup_completed | Once per session | ``` --- ## Task-Specific Questions 1. What tools are you using (GA4, Mixpanel, etc.)? 2. What key actions do you want to track? 3. What decisions will this data inform? 4. Who implements - dev team or marketing? 5. Are there privacy/consent requirements? 6. What's already tracked? --- ## Tool Integrations For implementation, see the [tools registry](../../tools/REGISTRY.md). Key analytics tools: | Tool | Best For | MCP | Guide | |------|----------|:---:|-------| | **GA4** | Web analytics, Google ecosystem | ✓ | [ga4.md](../../tools/integrations/ga4.md) | | **Mixpanel** | Product analytics, event tracking | - | [mixpanel.md](../../tools/integrations/mixpanel.md) | | **Amplitude** | Product analytics, cohort analysis | - | [amplitude.md](../../tools/integrations/amplitude.md) | | **PostHog** | Open-source analytics, session replay | - | [posthog.md](../../tools/integrations/posthog.md) | | **Segment** | Customer data platform, routing | - | [segment.md](../../tools/integrations/segment.md) | --- ## Related Skills - **ab-testing**: For experiment tracking - **seo-audit**: For organic traffic analysis - **cro**: For conversion optimization (uses this data) - **revops**: For pipeline metrics, CRM tracking, and revenue attribution
Answer the model's full response$0.13 · 67.5s · 7.9k tok
# Meta Conversion Tracking Implementation Guide: Cedar & Coil (Arc Clip Lamp) **Status:** Draft implementation guide (pre-launch; no active campaigns or historical performance data). **Storefront:** Shopify (DTC) **Product:** Arc Clip Lamp ($68.00 USD) --- ## 1. Recommended Architecture: Browser Pixel + Conversions API (CAPI) with Deduplication To send reliable conversion signals from Shopify to Meta without depending solely on browser cookies, implement a **dual-path (redundant) architecture**: 1. **Browser-side: Meta Pixel** running in the shopper's browser via Shopify's Customer Events / Web Pixels framework. 2. **Server-side: Meta Conversions API (CAPI)** sending events directly from the server (Shopify's servers or your own backend) to Meta's Graph API endpoint. 3. **Deduplication:** Both paths send the same conversion event with an identical `event_name` and `event_id`, allowing Meta to merge them into a single counted conversion. ### Why Both Are Needed - **Why Browser Pixel alone is insufficient:** Safari Intelligent Tracking Prevention (ITP), Firefox Enhanced Tracking Protection, ad blockers, iOS privacy restrictions, and unstable mobile connections can block Pixel scripts, shorten first-party cookie lifetimes, or drop checkout completion beacons before they fire. - **Why CAPI alone is insufficient:** The browser Pixel captures real-time client-side context—such as the `_fbp` browser cookie, `_fbc` click identifier from Meta ad clicks (`fbclid`), active browser session signals, and upper-funnel interactions—more reliably when the browser is not blocking scripts. - **Why combining them works:** When a browser allows the Pixel, Meta receives rich client context immediately. When a browser blocks the Pixel or drops a checkout beacon, the server-side CAPI request still delivers the confirmed event directly from the backend. Together, they improve signal resilience and Event Match Quality (EMQ) without double-counting conversions. --- ## 2. Standard Events and Key Parameters Track only the standard funnel events that inform Meta's ad delivery optimization and bidding decisions. Use Meta's exact standard event names (case-sensitive) and keep `content_ids` aligned with the product IDs synced to your Meta Commerce Catalog. | Standard Event | Trigger on Shopify | Required / Key Parameters | Arc Clip Lamp Example Values | | :--- | :--- | :--- | :--- | | **`ViewContent`** | Shopper loads the Arc Clip Lamp product detail page (PDP). | `content_ids`, `content_type`, `content_name`, `value`, `currency` | `content_ids: ["<variant_or_product_id>"]`, `content_type: "product"`, `content_name: "Arc Clip Lamp"`, `value: 68.00`, `currency: "USD"` | | **`AddToCart`** | Shopper clicks "Add to Cart" for the Arc Clip Lamp. | `content_ids`, `content_type`, `content_name`, `contents`, `value`, `currency` | `content_ids: ["<variant_or_product_id>"]`, `content_type: "product"`, `contents: [{"id": "<variant_or_product_id>", "quantity": 1, "item_price": 68.00}]`, `value: 68.00`, `currency: "USD"` | | **`InitiateCheckout`** | Shopper enters Shopify Checkout. | `content_ids`, `content_type`, `contents`, `num_items`, `value`, `currency` | `content_ids: ["<variant_or_product_id>"]`, `content_type: "product"`, `contents: [{"id": "<variant_or_product_id>", "quantity": 1, "item_price": 68.00}]`, `num_items: 1`, `value: 68.00`, `currency: "USD"` | | **`Purchase`** | Order is confirmed and paid (Thank You page / Shopify order webhook). | `value`, `currency`, `content_ids`, `content_type`, `contents`, `num_items` | `value: 68.00`, `currency: "USD"`, `content_ids: ["<variant_or_product_id>"]`, `content_type: "product"`, `contents: [{"id": "<variant_or_product_id>", "quantity": 1, "item_price": 68.00}]`, `num_items: 1` | ### Parameter Standards - **`value` and `currency`:** Always send `value` as a decimal number (not a string with a `$` sign) and `currency` as a 3-letter ISO 4217 code (`"USD"`). Decide once whether `value` represents order subtotal (excluding tax and shipping) or grand total, document it, and enforce the same definition in both Pixel and CAPI. - **`content_ids`:** Must match the exact ID format in your Meta Product Catalog (Shopify's native integration typically formats variant IDs as `shopify_US_<product_id>_<variant_id>` or uses the numeric Shopify product/variant ID depending on catalog settings). Mismatched IDs prevent dynamic catalog matching. - **`content_type`:** Use `"product"` when passing variant-level IDs or `"product_group"` when passing parent product IDs. --- ## 3. How Deduplication Works Between Pixel and CAPI Because both the browser Pixel and CAPI fire for the same user action, Meta must know that two incoming requests represent one event. ### The Deduplication Mechanism Meta deduplicates a browser event and a server event when **all** of the following match: 1. **Same Pixel / Dataset ID:** Both events are sent to the same Meta Dataset ID. 2. **Same `event_name`:** Exact string match (e.g., `"Purchase"` on both browser and server). 3. **Same `event_id`:** A unique, deterministic identifier generated for that specific event instance (for example, `purchase_<shopify_order_id>` or a UUID created per cart/checkout action and shared between browser and server). 4. **Within the deduplication window:** Meta evaluates matching `event_name` + `event_id` pairs received within **48 hours** of each other. ### How Meta Processes a Matching Pair - When Meta receives the first event (typically the browser Pixel event, though sometimes CAPI arrives first), it records it. - When the second event arrives with the same `event_name` and `event_id` within 48 hours, Meta marks it as **Deduplicated** and discards it from conversion counts so the `Purchase` is counted once. - If the browser Pixel is blocked and never arrives, Meta keeps the CAPI event as the sole record. ### Implementation Syntax Check - **Browser Pixel (`fbq`):** Pass `eventID` in the fourth argument object: ```javascript fbq('track', 'Purchase', { value: 68.00, currency: 'USD', content_ids: ['shopify_US_1234567890_9876543210'], content_type: 'product' }, { eventID: 'order_5678901234' }); ``` - **Server CAPI (JSON):** Pass `event_id` at the top level of the event object in `data[]`: ```json { "event_name": "Purchase", "event_id": "order_5678901234" } ``` *(Note the casing difference: `eventID` in the browser Pixel vs. `event_id` in the CAPI JSON payload.)* --- ## 4. Preparing Customer Information Server-Side Meta uses `user_data` parameters in CAPI requests to match server events to Meta user accounts. All Personally Identifiable Information (PII) **must be normalized and hashed with SHA-256** (lowercase hexadecimal) before leaving your server. Do **not** hash technical identifiers. ### Fields That MUST Be Normalized and SHA-256 Hashed | CAPI Field | Data | Normalization Rules (Before Hashing) | Example Raw -> Normalized | | :--- | :--- | :--- | :--- | | `em` | Email | Trim whitespace; convert to lowercase. | `" Alex@Example.com "` -> `"alex@example.com"` | | `ph` | Phone | Remove all symbols, spaces, letters, and leading zeros; include country code. | `"(555) 123-4567"` (US) -> `"15551234567"` | | `fn` | First Name | Lowercase; remove spaces and punctuation; UTF-8 Roman characters. | `"Alex "` -> `"alex"` | | `ln` | Last Name | Lowercase; remove spaces and punctuation; UTF-8 Roman characters. | `"O'Connor"` -> `"oconnor"` | | `ct` | City | Lowercase; remove spaces and punctuation. | `"San Francisco"` -> `"sanfrancisco"` | | `st` | State | Lowercase 2-letter ANSI state code (for US). | `"CA"` -> `"ca"` | | `zp` | Zip / Postal | Lowercase; remove spaces/dashes; US 5-digit zip only. | `"94107-1234"` -> `"94107"` | | `country` | Country | Lowercase 2-letter ISO 3166-1 alpha-2 code. | `"US"` -> `"us"` | | `external_id` | Customer ID | Optional; trim whitespace and hash with SHA-256 (recommended). | `"cust_90210"` -> SHA-256 hash | ### Fields That MUST NOT Be Hashed | CAPI Field | Data | Format / Source | | :--- | :--- | :--- | | `client_ip_address` | Shopper IP | Raw IPv4 or IPv6 address from the HTTP request. | | `client_user_agent` | Browser UA | Raw `User-Agent` header string from the shopper's browser. | | `fbp` | Browser ID | Raw value of the `_fbp` first-party cookie (e.g., `fb.1.1700000000000.1234567890`). | | `fbc` | Click ID | Raw value of the `_fbc` cookie, or constructed from the `fbclid` URL parameter as `fb.1.<timestamp_ms>.<fbclid>`. | Pass hashed fields (`em`, `ph`, `fn`, `ln`, etc.) as arrays of strings (e.g., `"em": ["<sha256_hash>"]`) per Meta's current CAPI schema. --- ## 5. Concrete Shopify Setup Path ### Option Comparison: Native Meta Sales Channel vs. Custom Implementation | Criterion | Native Shopify "Facebook & Instagram" App (Data Sharing: Maximum) | Custom Implementation (Shopify Custom Web Pixel + Backend Webhook / sGTM) | | :--- | :--- | :--- | | **Setup Effort** | Low (~30–60 minutes in Shopify Admin; no code). | High (developer build or third-party server-side GTM / middleware setup). | | **Ongoing Cost** | Free (included with Shopify). | Engineering maintenance and/or monthly server hosting / SaaS fees. | | **Deduplication** | Handled automatically by Shopify and Meta across Pixel + CAPI. | Must engineer shared `event_id` generation across browser Pixel and server webhook. | | **Catalog Alignment** | Automatically syncs Arc Clip Lamp catalog IDs with `content_ids`. | Must manually maintain ID format parity with Meta Catalog. | | **Shopify Checkout Compatibility** | Automatically updated for Shopify Checkout Extensibility and sandboxed Web Pixels. | Requires manual updates when Shopify or Meta deprecates API versions. | | **Payload Control** | Limited (cannot easily customize value formulas, filter draft/wholesale orders, or inspect raw CAPI logs). | Full control over payload enrichment, order filtering, and multi-channel routing. | | **Consent Integration** | Integrates natively with Shopify's Customer Privacy API. | Must explicitly read and enforce consent state in both Web Pixel and server webhook. | ### Recommendation for Cedar & Coil **Use the native Shopify "Facebook & Instagram" sales channel app with Data Sharing set to `Maximum`.** - **Why this serves the stated goal:** Cedar & Coil is a small, single-product DTC store preparing to launch its first Meta campaigns for the Arc Clip Lamp ($68). The immediate goal is reliable, privacy-resilient, deduplicated conversion tracking live before ad spend begins—without introducing custom-code bugs (`event_id` mismatches, dropped `fbp`/`fbc` forwarding, or broken consent checks). - **What it trades away:** You give up granular control over raw CAPI logs and custom event filtering (such as excluding manual draft orders or customizing revenue logic to net margin). Revisit a custom or server-side GTM setup only if Cedar & Coil later adds complex multi-channel server-side tagging, subscriptions, or offline order workflows. #### Step-by-Step Native Setup in Shopify 1. In Shopify Admin, install the official **Facebook & Instagram** sales channel by Meta. 2. Connect your Meta Business Portfolio, Facebook Page, Instagram Account, Ad Account, and Product Catalog. 3. In the sales channel **Settings -> Share data**, enable data sharing and select **Maximum** (this activates both the Meta Pixel and Conversions API with automatic deduplication). 4. Select or create the Meta Pixel/Dataset for Cedar & Coil and confirm the Arc Clip Lamp is synced and approved in Meta Commerce Manager. 5. Verify no legacy hardcoded Meta Pixel scripts remain in `theme.liquid` or Additional Scripts (which would cause duplicate browser events). ### Code Sketch: Server-Side `Purchase` Event Request (Custom Reference) If you later build a custom server-side handler (for example, triggered by a Shopify `orders/paid` webhook) or want to understand the exact payload structure sent to Meta's Graph API, use the following Node.js pattern: ```javascript import crypto from "crypto"; function sha256(value) { return crypto.createHash("sha256").update(value).digest("hex"); } function normalizeAndHash(value, type) { if (!value) return undefined; let cleaned = String(value).trim().toLowerCase(); if (type === "ph") { cleaned = cleaned.replace(/[^0-9]/g, "").replace(/^0+/, ""); } else if (type === "zp") { cleaned = cleaned.replace(/[^a-z0-9]/g, "").slice(0, 5); // US 5-digit } else if (type === "ct" || type === "fn" || type === "ln") { cleaned = cleaned.replace(/[^a-z]/g, ""); } return cleaned ? [sha256(cleaned)] : undefined; } async function sendMetaCapiPurchase(order, browserContext) { const PIXEL_ID = process.env.META_PIXEL_ID; const ACCESS_TOKEN = process.env.META_CAPI_ACCESS_TOKEN; const API_VERSION = "v21.0"; // Must match the exact eventID sent by the browser Pixel for this order const eventId = `purchase_${order.id}`; const payload = { data: [ { event_name: "Purchase", event_time: Math.floor(new Date(order.created_at).getTime() / 1000), event_id: eventId, action_source: "website", event_source_url: `https://cedarandcoil.com/checkouts/${order.checkout_token}/thank_you`, user_data: { em: normalizeAndHash(order.email, "em"), ph: normalizeAndHash(order.phone, "ph"), fn: normalizeAndHash(order.billing_address?.first_name, "fn"), ln: normalizeAndHash(order.billing_address?.last_name, "ln"), ct: normalizeAndHash(order.billing_address?.city, "ct"), st: normalizeAndHash(order.billing_address?.province_code, "st"), zp: normalizeAndHash(order.billing_address?.zip, "zp"), country: normalizeAndHash(order.billing_address?.country_code, "country"), // Unhashed technical identifiers captured at checkout client_ip_address: browserContext.ip, client_user_agent: browserContext.userAgent, fbp: browserContext.fbp, fbc: browserContext.fbc, }, custom_data: { currency: order.currency || "USD", value: Number(order.subtotal_price || 68.0), content_type: "product", content_ids: order.line_items.map((item) => `shopify_US_${item.product_id}_${item.variant_id}`), contents: order.line_items.map((item) => ({ id: `shopify_US_${item.product_id}_${item.variant_id}`, quantity: item.quantity, item_price: Number(item.price), })), num_items: order.line_items.reduce((sum, item) => sum + item.quantity, 0), }, // Include if Limited Data Use applies (see Section 7) // data_processing_options: ["LDU"], // data_processing_options_country: 0, // data_processing_options_state: 0, }, ], // Remove test_event_code in production test_event_code: process.env.META_TEST_EVENT_CODE, }; const response = await fetch( `https://graph.facebook.com/${API_VERSION}/${PIXEL_ID}/events?access_token=${ACCESS_TOKEN}`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(payload), } ); if (!response.ok) { const errorBody = await response.text(); throw new Error(`Meta CAPI error (${response.status}): ${errorBody}`); } return response.json(); } ``` --- ## 6. End-to-End Validation Before Scaling Spend Do not launch paid campaigns until every item below passes. Treat any failed check as an observed defect to fix before spending; if counts later diverge, treat the defect as a hypothesis until debug logs confirm the mechanism. ### Step 1: Real-Time Funnel Test in Meta Events Manager 1. Open **Meta Events Manager -> Data Sources -> [Cedar & Coil Dataset] -> Test Events**. 2. Enter your Shopify store URL under **Confirm your website's events are set up correctly** (and, if testing custom CAPI, copy the `TEST#####` code into `test_event_code`). 3. Walk through a full shopper journey in a clean browser window (ad blocker off first): - Visit the Arc Clip Lamp PDP -> verify `ViewContent`. - Click Add to Cart -> verify `AddToCart`. - Enter Checkout -> verify `InitiateCheckout`. - Complete a real test order (using Shopify's Bogus Gateway or a 100% discount/refunded test transaction) -> verify `Purchase`. ### Step 2: Verification Checklist - [ ] **Dual Receipt:** In Test Events, each standard event (`ViewContent`, `AddToCart`, `InitiateCheckout`, `Purchase`) shows **both** `Browser` and `Server` in the *Connection Method* column. - [ ] **Deduplication Confirmed:** On the paired events, the second event received displays **Deduplicated** (confirming matching `event_name` and `event_id`). - [ ] **Parameter Integrity:** Expand the `Purchase` event and verify `value` (`68.00`), `currency` (`USD`), `content_ids` (matching the Meta Catalog ID for the Arc Clip Lamp), `content_type`, and `num_items`. - [ ] **No Double Browser Firing:** Use the **Meta Pixel Helper** Chrome extension on the PDP and Thank You page to confirm each event fires once per action (no leftover hardcoded Pixel in `theme.liquid`). - [ ] **Server Fallback Check:** Repeat a test order in a browser with an ad blocker enabled or strict tracking prevention. Confirm the `Server` CAPI `Purchase` event still arrives in Events Manager even when the browser Pixel is blocked. - [ ] **Event Match Quality (EMQ):** After accumulating live traffic and test conversions, check **Events Manager -> Overview -> Event Match Quality** for `Purchase`. Confirm email, phone, IP, User-Agent, `fbp`, and `fbc` are being received and hashed properly where required. - [ ] **Order Reconciliation (Post-Launch Soft Test):** Before scaling spend, compare Shopify completed online orders against Meta Events Manager total `Purchase` events over the **exact same closed date window** (e.g., complete days in the same time zone, never mixing partial-day data). Investigate any large unexplained gap or over-counting before increasing budget. --- ## 7. Consent and Compliance Note Server-side tracking does **not** exempt Cedar & Coil from privacy regulations. Because CAPI sends data from the server rather than the browser, it is easy to accidentally bypass a shopper's cookie opt-out if consent is not wired into both paths. - **Honor Opt-Outs on Both Pixel and CAPI:** Configure Shopify's built-in Cookie Banner / Customer Privacy settings (or a Consent Management Platform integrated with Shopify's Customer Privacy API). In the native Meta sales channel, Shopify suppresses both browser Pixel and CAPI marketing events when a visitor in a regulated region (such as the EU/UK under GDPR/ePrivacy or US states with opt-out rights) declines marketing consent. If using a custom implementation, you must explicitly check consent status before firing the Web Pixel *and* before sending the server-side CAPI webhook. - **US State Privacy & Meta Limited Data Use (LDU):** For shoppers in California (CCPA/CPRA) and other applicable US states where users opt out of data "sale" or "sharing" for targeted advertising, enable Meta's **Limited Data Use (LDU)** flag (`data_processing_options: ["LDU"]` with country/state codes) in both Pixel and CAPI—or let Shopify's Customer Privacy settings manage US opt-out signals automatically. - **Data Minimization & No Raw PII Leaks:** Never pass raw PII (email, phone, full name, street address) in `custom_data`, custom event names, or unhashed URL query strings. Only send PII in the designated, SHA-256-hashed `user_data` fields. - **Privacy Policy Disclosure:** Update Cedar & Coil's privacy policy before launching ads to disclose the use of Meta Pixel, server-side conversion tracking (Conversions API), and how shoppers can opt out of targeted advertising. *(This section provides operational implementation guidance, not legal advice; confirm regional consent requirements with legal counsel for your target markets.)*
Score the judge's verdict, criterion by criterion10/11 criteria passed · failed: sources_defined
RequirementVerdictEvidence
architecture
The guide recommends browser Pixel plus server-side Conversions API with deduplication and explains why both are needed under browser privacy limits.
✓Section 1 recommends Pixel plus CAPI with shared event_name/event_id, and explains why each alone is insufficient (ITP, ETP, ad blockers, iOS limits).
events_mapped
All four standard events (ViewContent, AddToCart, InitiateCheckout, Purchase) are covered with key parameters, including value, currency, and content_ids on Purchase.
✓The Section 2 table covers ViewContent, AddToCart, InitiateCheckout and Purchase with key parameters, and Purchase lists value, currency and content_ids.
code_sketch
A concrete server-side Purchase event code sketch or request example is included showing event_name, event_time, event_id, action_source, and a user_data block.
✓The Node.js sketch builds a payload with event_name "Purchase", 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 uses Events Manager Test Events and a checklist item that the second event shows "Deduplicated" with both Browser and Server connection methods.
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 table gives a Shopify trigger per event but never says which events fire from the browser versus the server or what the source of truth is. Purchase is only "Thank You page / Shopify order webhook", with no clear designation.
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 gives no attribution-recovery percentages (only "improve signal resilience") and Section 7 says consent and regional rules constrain what may be sent, with a not-legal-advice note.
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 requires the same dataset, the same event_name and the same event_id on both paths, with fbq eventID and CAPI event_id examples and the 48-hour window.
event_id_retry_stability
The event_id is generated or derived once per commerce event, shared by browser and server, and reused unchanged on webhook retries or order updates; a new random suffix per send or retry fails.
✓The event_id is deterministic, `purchase_${order.id}` (also "purchase_<shopify_order_id>" in Section 3), with no random suffix, so it stays the same on webhook retries and matches the browser 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 `Math.floor(new Date(order.created_at).getTime() / 1000)`, the order timestamp in Unix seconds, not the send time, so retries keep it unchanged.
pii_hashing
Customer data handling is correct: personally identifiable fields (e.g. email) are normalized (trimmed, lowercased) and SHA-256 hashed before sending in user_data.
✓Section 4 and the code trim, lowercase and normalize email, phone and names, then SHA-256 hash them, and leave IP, user agent, fbp and fbc unhashed.
actionable_path
The recommended Shopify path is decisive and executable for a small DTC store (a clear recommendation with concrete setup steps, not an undifferentiated list of options).
✓It compares the native app with a custom build, decisively recommends the native Facebook & Instagram app with Data Sharing set to Maximum, and gives five concrete setup steps.