# Cedar & Coil: Meta Conversion Tracking Implementation Guide
**Store:** Shopify | **Product:** Arc Clip Lamp ($68) | **Status:** Draft. No campaign has launched and no performance data exists.
This guide explains how to build conversion tracking from the Cedar & Coil Shopify store into Meta that holds up under browser privacy limits. It makes no claims about how much attribution you will recover. Treat any improvement as something you measure after launch, not something you expect in advance.
---
## 1. Recommended Architecture: Meta Pixel + Conversions API with Deduplication
**Use both a browser Meta Pixel and server-side Conversions API (CAPI), sending matching events that Meta deduplicates.**
```
Shopper's browser Your server / Shopify
───────────────── ─────────────────────
Meta Pixel (fbq) Conversions API (HTTPS POST)
ViewContent ─┐ ┌─ ViewContent (optional)
AddToCart ─┤ same event_name ├─ AddToCart (optional)
InitCheckout ─┤ + same event_id ├─ InitiateCheckout
Purchase ─┘──────────┐ ┌──────────┘─ Purchase (required)
▼ ▼
Meta Events Manager
(deduplicates → one event)
```
### Why you need both
| | Browser Pixel | Conversions API |
|---|---|---|
| **Strengths** | Captures on-page context: `_fbp`/`_fbc` cookies, page URL, and real-time browsing behavior. Easy to fire on every page interaction. | Runs from a server, so ad blockers, browser tracking prevention, cookie expiry, and closed tabs don't affect it. Sends authoritative order data from Shopify. |
| **Weaknesses** | Ad blockers, Safari ITP, restricted third-party scripts, network failures, or a shopper leaving before the script fires can all block it. | Has no direct view of browser context. It only knows `fbp`, `fbc`, IP, and user agent if you capture and pass them through. |
The two channels cover each other's gaps:
- **The Pixel supplies browser signals** (click ID, browser ID) that help Meta tie events to ad interactions.
- **CAPI provides a reliable record** of high-value events, especially Purchase, even when the browser event is lost.
Without deduplication, each purchase would be counted twice. Section 3 explains how deduplication works.
---
## 2. Standard Events and Parameters
Send these four standard events. Use Meta's exact standard event names (case-sensitive), not custom names.
### Shared parameter rules
- **`currency`**: ISO 4217 code, e.g. `"USD"`. Required whenever you send `value`.
- **`value`**: A number, not a string (`68.00`, not `"$68"`).
- **`content_ids`**: An array of product identifiers. **They must match the IDs in your Meta product catalog.** The Shopify Meta channel typically syncs catalog items using a Shopify-specific ID format based on product and variant IDs. Before hardcoding anything, look up the actual IDs in Commerce Manager → Catalog → Items.
- **`content_type`**: `"product"` when IDs refer to individual items or variants, `"product_group"` when they refer to parent products.
- **`contents`**: An array of `{id, quantity, item_price}` objects. This gives more detail than `content_ids` alone.
### Event reference
| Event | Fires when | Key parameters |
|---|---|---|
| **ViewContent** | Arc Clip Lamp product page loads | `content_ids`, `content_type`, `content_name` ("Arc Clip Lamp"), `value` (68.00), `currency` |
| **AddToCart** | Shopper adds the lamp to cart | `content_ids`, `content_type`, `contents` (with quantity), `value` (unit price × quantity), `currency` |
| **InitiateCheckout** | Checkout starts | `content_ids`, `contents`, `num_items`, `value` (cart total), `currency` |
| **Purchase** | Order completes | **`value`**, **`currency`**, **`content_ids`** (all required here), plus `contents`, `content_type`, `num_items`, `order_id` |
### Purchase example (one lamp, no discount)
```json
{
"value": 68.00,
"currency": "USD",
"content_ids": ["<catalog_id_for_arc_clip_lamp_variant>"],
"content_type": "product",
"contents": [{ "id": "<catalog_id_for_arc_clip_lamp_variant>", "quantity": 1, "item_price": 68.00 }],
"num_items": 1,
"order_id": "<shopify_order_id>"
}
```
### Define `value` once and keep it consistent
Decide and document whether Purchase `value` means:
- subtotal after discounts,
- subtotal plus shipping, or
- the full total including tax.
The recommended default is **subtotal after discounts, excluding tax and shipping**, because it best reflects product revenue. Whichever you choose, the Pixel and CAPI must report the same figure. Otherwise reporting will show mismatched values across sources.
---
## 3. How Deduplication Works Between Pixel and CAPI
When Meta receives a browser event and a server event that describe the same action, it keeps one and discards the other. It decides they match using two keys.
### The deduplication keys
| Pixel (browser) | CAPI (server) | Must match |
|---|---|---|
| Event name in `fbq('track', 'Purchase', …)` | `event_name: "Purchase"` | Exactly, including case |
| `eventID` in the 4th argument of `fbq` | `event_id` | Exactly, as the same string |
```js
// Browser
fbq('track', 'Purchase',
{ value: 68.00, currency: 'USD', content_ids: ['…'], content_type: 'product' },
{ eventID: 'purchase_5551234567890' } // ← dedup key
);
```
```json
// Server (CAPI)
{ "event_name": "Purchase", "event_id": "purchase_5551234567890", ... }
```
### Rules that make deduplication work
1. **Build event IDs from data both sides can see.** For Purchase, use the Shopify order ID (e.g. `purchase_{order_id}`). The browser can read it on the post-purchase page, and the server receives it in the order webhook. For earlier funnel events, generate a UUID in the browser and pass it to your server along with the event.
2. **Make IDs unique per action and stable across both channels.** Never reuse one ID for different actions. Never generate separate random IDs on each side.
3. **Send both events promptly.** Meta's documentation describes a deduplication window of up to 48 hours after the first event. Don't rely on the edge of that window. Send server events in near real time.
4. **Send each event from exactly one browser source and one server source.** If both the native Meta app and a custom script fire a Pixel Purchase, you will double count, even with deduplication, unless they share event IDs. This is the most common cause of inflated Purchase counts on Shopify.
5. **Don't rely on fallback matching.** Meta can also attempt deduplication using `fbp` or `external_id`, but that is less reliable. Always send `event_id`.
### How to tell deduplication is working
In Events Manager, open the event and check its details. The event should list both **Browser** and **Server** as sources, and the overview should report deduplication. If the Purchase count is about double your Shopify order count for the same period, deduplication is failing.
---
## 4. Preparing Customer Information for Server-Side Events
CAPI events carry a `user_data` object that Meta uses to match events to people. Any personal identifiers in it **must be normalized, then hashed with SHA-256** before sending. Technical identifiers must be sent **unhashed**.
### Hash these (normalize first, then SHA-256, output as lowercase hex)
| Field | Key | Normalization before hashing |
|---|---|---|
| Email | `em` | Trim whitespace, lowercase |
| Phone | `ph` | Digits only, including country code (e.g. `15551234567`). No `+`, spaces, or dashes. |
| First name | `fn` | Lowercase, trim, remove punctuation |
| Last name | `ln` | Lowercase, trim, remove punctuation |
| City | `ct` | Lowercase, remove spaces and punctuation (e.g. `sanfrancisco`) |
| State | `st` | 2-letter code, lowercase (e.g. `ca`) |
| Zip | `zp` | Lowercase, no spaces. For US, first 5 digits only. |
| Country | `country` | ISO 3166-1 alpha-2, lowercase (e.g. `us`) |
| External ID | `external_id` | Your stable customer ID (e.g. Shopify customer ID). Hashing is recommended. |
### Do **not** hash these
| Field | Key | Source |
|---|---|---|
| Client IP address | `client_ip_address` | The shopper's IP, from the browser request or Shopify order `client_details` |
| User agent | `client_user_agent` | The shopper's browser UA string. Required for website events. |
| Click ID | `fbc` | The `_fbc` cookie, or built from the `fbclid` URL parameter |
| Browser ID | `fbp` | The `_fbp` cookie |
### Common mistakes
- **Hashing before normalizing.** `Jane@Example.com` and `jane@example.com` produce different hashes, so matching fails.
- **Hashing twice,** or hashing `fbp`/`fbc`/IP/user agent.
- **Sending the server's IP and user agent** instead of the shopper's.
- **Losing `fbp`/`fbc` server-side.** A Shopify order webhook does not include the shopper's cookies. In a custom build, capture `_fbp` and `_fbc` in the browser and write them to the cart, e.g. as cart attributes via the Ajax Cart API. They then appear on the order as `note_attributes`, where your server can read them.
- **Sending identifiers you lack consent to send.** See Section 7.
Event Match Quality in Events Manager shows how useful your customer data is to Meta. Use it to diagnose problems, not as a target to maximize at the expense of consent.
---
## 5. Shopify Setup Path
### Option A: Native Meta app (Shopify's "Facebook & Instagram" sales channel)
**What it does:**
- Installs the Meta Pixel.
- Enables Conversions API when you set data sharing to the **Maximum** level.
- Handles event IDs and deduplication between browser and server.
- Syncs your product catalog, so `content_ids` match the catalog automatically.
- Integrates with Shopify's Customer Privacy API for consent.
**Setup steps:**
1. In Shopify admin, install the **Facebook & Instagram** app (sales channel) from the Shopify App Store.
2. Connect the correct Meta Business portfolio, ad account, Facebook Page, and Pixel (dataset). Create a new Pixel if one doesn't exist. **Avoid connecting a Pixel that is already used by another store.**
3. Under data sharing settings, choose **Maximum**. This is the setting that enables server-side events through CAPI.
4. Enable catalog sync and confirm the Arc Clip Lamp appears in Commerce Manager with its correct price ($68) and availability.
5. **Remove all other Meta Pixel code:**
- hardcoded `fbq` snippets in theme files,
- legacy Additional Scripts on the order status page,
- other tracking apps that also send Meta events,
- Meta tags in Google Tag Manager.
6. In Meta Business settings, verify your store's domain.
7. Run the validation steps in Section 6.
**Trade-offs:**
- **Pros:** Little engineering work. Maintained by Shopify and Meta as their APIs change. Deduplication and catalog ID matching are handled for you. Works with Shopify's checkout extensibility model.
- **Cons:** Limited control over the exact payload, such as how `value` is defined or which customer fields are sent. Debugging is less transparent. Custom events require a separate setup.
### Option B: Custom implementation
**What it involves:**
1. **Browser side:** A custom pixel in Shopify admin → Settings → **Customer events**, using the Web Pixels API. Subscribe to `product_viewed`, `product_added_to_cart`, `checkout_started`, and `checkout_completed`, and call `fbq` from those handlers with your own `eventID`s.
- Note: Shopify has been deprecating `checkout.liquid` and order-status "Additional Scripts" in favor of Customer Events. Don't build new tracking on the deprecated paths.
- Custom pixels run in a sandbox, so browser tools like Meta Pixel Helper may not show them reliably. Rely on Events Manager's Test Events instead.
2. **Server side:** A small service (serverless function or app backend) that:
- receives Shopify `orders/create` or `orders/paid` webhooks,
- verifies the webhook's HMAC signature,
- builds the CAPI payload, and
- POSTs it to Meta's Graph API.
3. **Shared keys:** Use `purchase_{order_id}` as the event ID on both sides. Pass `fbp`/`fbc` through cart attributes (see Section 4).
4. **Operations:** Store the access token securely, add retry logic, log failures, update the Graph API version over time, and send each order only once even when Shopify retries a webhook.
**Trade-offs:**
- **Pros:** Full control over payloads, value definitions, and customer fields. Transparent debugging.
- **Cons:** Ongoing engineering and maintenance. More ways to break deduplication or double count. You must implement consent handling yourself.
### Recommendation for Cedar & Coil
**Use the native Facebook & Instagram app with Maximum data sharing.**
Cedar & Coil is a small DTC brand with one hero product and no existing tracking history. The native app gives Pixel, CAPI, deduplication, catalog matching, and consent integration with the least risk of a self-inflicted tracking bug.
Consider a custom CAPI build later only if validation reveals a specific gap the app can't close, such as needing a different Purchase `value` definition. **Never run both for the same events at the same time.**
### Code sketch: server-side Purchase event (custom path, for reference)
This Node.js sketch shows what a CAPI Purchase request contains. It is illustrative, not production-ready: it omits retries, persistent idempotency storage, and full error handling.
```js
// purchase-capi.js — illustrative sketch (Node 18+, native fetch)
import crypto from 'node:crypto';
const PIXEL_ID = process.env.META_PIXEL_ID;
const ACCESS_TOKEN = process.env.META_CAPI_TOKEN; // System User token; never expose client-side
const API_VERSION = process.env.META_API_VERSION; // e.g. a current "vXX.0"; update as Meta deprecates versions
const SHOP_DOMAIN = 'https://cedarandcoil.example'; // placeholder
const sha256 = (s) => crypto.createHash('sha256').update(s).digest('hex');
const hashIf = (s) => (s ? sha256(s) : undefined);
// --- Normalizers (normalize BEFORE hashing) ---
const normEmail = (v) => v?.trim().toLowerCase();
const normPhone = (v) => v?.replace(/\D/g, ''); // assumes country code present
const normName = (v) => v?.trim().toLowerCase().replace(/[^\p{L}]/gu, '');
const normCity = (v) => v?.toLowerCase().replace(/[^\p{L}]/gu, '');
const normState = (v) => v?.trim().toLowerCase();
const normZip = (v, cc) => {
const z = v?.trim().toLowerCase().replace(/\s/g, '');
return cc?.toLowerCase() === 'us' ? z?.slice(0, 5) : z;
};
const normCountry = (v) => v?.trim().toLowerCase();
// Read fbp/fbc that the storefront wrote into cart attributes
const attr = (order, name) =>
order.note_attributes?.find((a) => a.name === name)?.value;
// Map Shopify line items to the IDs used in your Meta catalog.
// IMPORTANT: confirm the real catalog ID format in Commerce Manager.
const toCatalogId = (li) => String(li.variant_id);
export async function sendPurchaseToMeta(order, { consentGranted }) {
if (!consentGranted) return { skipped: 'no marketing consent' }; // see Section 7
const b = order.billing_address ?? {};
const contents = order.line_items.map((li) => ({
id: toCatalogId(li),
quantity: li.quantity,
item_price: Number(li.price),
}));
const payload = {
data: [{
event_name: 'Purchase',
event_time: Math.floor(new Date(order.created_at).getTime() / 1000), // unix seconds
event_id: `purchase_${order.id}`, // MUST equal the browser Pixel eventID
action_source: 'website',
event_source_url: `${SHOP_DOMAIN}/checkout`,
user_data: {
em: hashIf(normEmail(order.email)),
ph: hashIf(normPhone(order.phone ?? b.phone)),
fn: hashIf(normName(b.first_name)),
ln: hashIf(normName(b.last_name)),
ct: hashIf(normCity(b.city)),
st: hashIf(normState(b.province_code)),
zp: hashIf(normZip(b.zip, b.country_code)),
country: hashIf(normCountry(b.country_code)),
external_id: hashIf(order.customer?.id ? String(order.customer.id) : undefined),
// NOT hashed:
client_ip_address: order.client_details?.browser_ip,
client_user_agent: order.client_details?.user_agent,
fbp: attr(order, '_fbp'),
fbc: attr(order, '_fbc'),
},
custom_data: {
currency: order.currency, // e.g. "USD"
value: Number(order.current_subtotal_price), // your documented value definition
content_ids: contents.map((c) => c.id),
content_type: 'product',
contents,
num_items: contents.reduce((n, c) => n + c.quantity, 0),
order_id: String(order.id),
},
}],
// test_event_code: 'TEST12345', // enable ONLY while validating in Test Events
};
const res = 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) }
);
const body = await res.json();
if (!res.ok) throw new Error(`CAPI error: ${JSON.stringify(body)}`);
return body; // includes events_received and fbtrace_id for debugging
}
```
**Notes on the sketch:**
- `JSON.stringify` drops fields that are `undefined`, so missing customer data is simply omitted.
- `event_time` must be recent. Meta rejects events older than its allowed window, so send promptly rather than in delayed batches.
- Shopify may deliver the same webhook more than once. Record processed order IDs so you send each Purchase only once. The shared `event_id` also protects against duplicates on Meta's side.
- The matching browser call, inside a Customer Events custom pixel, would subscribe to `checkout_completed` and fire `fbq('track', 'Purchase', {...}, { eventID: 'purchase_' + orderId })` using the order ID from the event data.
---
## 6. End-to-End Validation Before Scaling Spend
Complete this checklist before spending anything beyond a minimal test budget.
### A. Configuration audit
- [ ] Exactly **one** Pixel (dataset) is connected to the store, and it is the one selected in the ad account.
- [ ] No duplicate Meta tracking exists in theme code, GTM, legacy checkout scripts, or other apps. Search theme files for `fbq(` and `connect.facebook.net`.
- [ ] Data sharing is set to **Maximum** (native path), or the CAPI endpoint is live (custom path).
- [ ] Your domain is verified in Meta Business settings.
- [ ] The catalog shows the Arc Clip Lamp at $68 with correct availability.
### B. Live test with Test Events
1. In Events Manager → your dataset → **Test Events**, open the test browser tool or copy the test event code (for a custom CAPI path, add `test_event_code` temporarily).
2. Walk through the full funnel in a normal browser session with consent accepted: product page, add to cart, start checkout, complete purchase. Use a real order with a 100% discount code, or a low-cost test product, then refund or cancel the order.
3. Confirm each event appears with the following checks:
| Check | Expected |
|---|---|
| ViewContent, AddToCart, InitiateCheckout, Purchase all received | ✅ |
| Purchase received from **both Browser and Server** | ✅ |
| Purchase shows as **deduplicated** (one event, not two) | ✅ |
| `value` matches your documented definition and the Shopify order | e.g. 68.00 for one lamp at full price |
| `currency` | `USD` (or the store currency) |
| `content_ids` match catalog item IDs | ✅ |
| Customer parameters present (hashed email, IP, UA, fbp; fbc when arriving from an ad click) | ✅ |
4. Repeat in a **privacy-restricted browser** (e.g. Safari, or a browser with an ad blocker). The server-side Purchase should still arrive even if the browser event does not. This is the scenario CAPI exists to cover.
5. Repeat with **consent declined** and confirm marketing events behave according to your consent policy (see Section 7).
6. Test an edge case: two lamps, or an order with a discount code. Confirm `value`, `num_items`, and `contents` are correct.
### C. Post-test checks (24–72 hours)
- [ ] The **Diagnostics** tab in Events Manager shows no unresolved errors: deduplication issues, missing parameters, invalid currency or value, or catalog ID mismatches.
- [ ] **Event Match Quality** for Purchase is reported and has no flagged missing fields you could legitimately send.
- [ ] **Reconcile counts:** Meta Purchase events for the test window ≈ Shopify orders for the same window. A count near 2× means deduplication failed. A count well below means events are being dropped.
- [ ] Remove `test_event_code` from any production code.
### D. Ongoing monitoring after launch
- Once spend starts, compare Shopify orders with Meta-reported Purchases weekly. Some gap between them is normal and expected. Track it over time rather than against an assumed recovery target.
- Re-validate after any change to the theme, checkout, apps, or Meta app settings.
- Remember that no performance data exists yet. Baselines must come from Cedar & Coil's own post-launch data, not industry benchmarks or assumptions.
---
## 7. Consent and Compliance Note
*This is operational guidance, not legal advice. Have counsel review the setup for every market where Cedar & Coil sells.*
- **CAPI does not bypass consent.** Server-side sending makes tracking resilient to technical blockers like ad blockers and cookie restrictions. It does not change your legal obligations. If a shopper has not consented, or has opted out, where consent or opt-out is required, do not send their data to Meta through either channel.
- **Use Shopify's consent tooling.** Turn on Shopify's cookie and consent banner (Customer Privacy settings), or a compatible consent management app, for regions that require it, such as the EU, UK, and certain US states. The native Meta app respects Shopify's Customer Privacy API signals. A custom implementation must read and enforce those signals itself, in both the custom pixel and the server-side sender.
- **Honor US opt-out rights.** For shoppers in US states with privacy laws, support "Do Not Sell or Share" opt-outs. Consider Meta's **Limited Data Use** data processing option on events from those users, and confirm current requirements in Meta's documentation.
- **Disclose it in your privacy policy.** It should explain that the store shares browsing and purchase data, including hashed contact details, with Meta for advertising and measurement, and how shoppers can opt out.
- **Minimize data.** Send only the standard parameters described above. Never send sensitive data or free-text fields such as order notes. Never put personal data in custom parameters or URLs.
- **Accept Meta's terms.** Accept Meta's Business Tools terms for the dataset, and keep the CAPI access token restricted to the people and systems that need it.
- **Keep campaign work draft-only.** All campaign work remains draft-only until approved. Ad copy that eventually runs on this tracking must stay within approved claims: no invented reviews, awards, scarcity, environmental claims, performance guarantees, or customer results. The approved CTA is "Explore the Arc Clip Lamp."