I'll check the current Meta and Shopify documentation so the setup steps match today's interfaces.# Cedar & Coil: Arc Clip Lamp Meta Conversion Tracking Implementation Guide
No campaign has launched and no performance data exists yet, so this guide covers measurement integrity, not results. Keep the Meta campaigns in draft until the gates in Section 6 pass. Some vendor blogs disagree on details, so confirm each parameter and threshold against Meta's developer docs before you build.
## 1. Recommended architecture
Run two paths that describe the same real-world action and share one identity:
- **Browser lane:** the Meta Pixel fires ViewContent, AddToCart, InitiateCheckout, and Purchase from the visitor's browser, each with an event ID.
- **Server lane:** the Conversions API (CAPI) sends the same events from Shopify or your server, with the same event name and event ID.
- **Meta side:** Meta keeps one copy of each matched pair.
Why both are needed:
- **Browser-only loses data.** Ad blockers can block the web pixel entirely, and tracking prevention shortens or limits cookies.
- **Server-only loses browser signals.** The browser supplies cookies and request details that help matching. The fbp and fbc cookies and external_id improve matching, and server-side requests don't carry them by default.
- **Redundancy is Meta's own recommendation.** Meta itself recommends that you always use the Conversions API along with a Meta pixel.
- **The server lane survives browser failures.** Meta CAPI runs server-side, so it keeps reporting even when the browser does not.
For a small Shopify store, the native Facebook & Instagram channel can run both lanes (see Section 5). Don't add a second Meta pixel in the theme. Delete any pixel you hardcoded into your theme, because two pixels firing double counts everything.
## 2. Standard events and key parameters
Only Purchase needs strict parameters, but send the rest consistently so ads can optimize on the same product data.
- **Purchase:** A Purchase event requires value and currency. content_ids, content_type, num_items, and event_id are strongly recommended for Conversions API deduplication. Currency must be explicit: a €100 order and a $100 order both passing value: 100 without currency become indistinguishable in Meta's reporting.
- **content_ids:** If the page is about a specific SKU, use product for content_type and pass the product IDs (the id column in the Product Feed) in content_ids. Use the same IDs as your Commerce Manager catalog.
- **content_type:** All AddToCart and Purchase events should use content_type=product because people buy specific products.
| Event | Fires when | Key parameters | Notes |
|---|---|---|---|
| ViewContent | Arc Clip Lamp product page loads | content_ids, content_type=product, content_name, value, currency | Use the catalog ID. Send value 68.00 USD if the price is known. |
| AddToCart | Lamp added to cart | content_ids, content_type, value (line total), currency | Use the cart token as the event ID (see Section 3). |
| InitiateCheckout | Checkout starts | value (cart total), currency, num_items, content_ids | Use the checkout token as the event ID. |
| Purchase | Paid order confirmed | value, currency, content_ids, content_type=product, contents (id, quantity, item_price), num_items, event_id = order ID | Server and browser values must match exactly. |
Purchase example for the browser lane (the $68 price comes from facts.md; the content ID is a placeholder):
```javascript
fbq('track', 'Purchase',
{ value: 68.00, currency: 'USD', content_type: 'product',
content_ids: ['ARC-CLIP-LAMP'], num_items: 1 },
{ eventID: '8472' }); // the Shopify order ID, identical on the server
```
Decide once whether `value` means order total (including tax and shipping) or subtotal, then use that definition in both lanes.
## 3. How deduplication works
Meta counts a browser event and a server event once when these conditions hold:
1. **The IDs match.** In corresponding events, a Meta Pixel's eventID must match the Conversion API's event_id. The pixel passes the ID as the fourth argument in the fbq track call.
2. **The names match.** In corresponding events, a Meta Pixel's event must match the Conversion API's event_name.
3. **Timing falls within the window.** Events are only deduplicated if they arrive within 48 hours of the first event Meta received with that event_id.
4. **Both sources target the same pixel.** Deduplication applies for events sent to the same pixel ID.
When Meta finds a match, Meta keeps one copy and discards the other.
**ID generation rules for Shopify:**
- Purchase: use the order ID. Most stores can reuse the Shopify order_id as the Purchase event_id.
- AddToCart and ViewContent: use the cart token. InitiateCheckout: use the checkout token. Use cart.token for AddToCart and ViewContent, checkout.token for InitiateCheckout, and order.id for Purchase.
- Generate the ID once at the source of the action and pass it to both lanes. A random ID generated separately on each side is the most common cause of double counting.
**Failure modes to watch:**
- **Missing ID:** Miss the shared id and nothing dedupes.
- **Mismatched IDs:** If the IDs differ, the purchase is counted twice.
- **Reused IDs:** One ID reused across real actions makes Meta discard a real later purchase. A cart token reused across two orders is one example.
- **Two server senders:** Shopify's app plus another tool, or a Conversions API Gateway left connected, each create their own IDs, so the fallback never pairs two server events. Keep one server sender per pixel.
- **Optional field:** Meta marks event_id as optional but recommends it for deduplication. Treat it as required in your build.
## 4. Preparing customer information before sending server-side
Each server event needs at least one customer information parameter. The rules below come from Meta's parameter guidance and vendor documentation.
**Normalize first, then hash:**
- **Email:** trim leading and trailing spaces and convert to lowercase.
- **Phone:** remove symbols, letters and leading zeros, and always include the country code. A UK example: a UK number like 07700 900123 becomes 447700900123.
- **Country:** the lowercase two-letter ISO 3166-1 code, such as us.
- **Hashing:** All customer information parameters should be hashed as SHA256, except for client IP address, client user agent, click ID, and browser ID. Hashing the wrong field is harmful: hashing those two makes the event unmatchable. (The "two" there refers to the unhashed fields.)
**Do not hash these:**
- client_ip_address, client_user_agent, fbc, and fbp (as listed above).
- **fbc format:** the click ID follows a pattern built from the fbclid exactly as received.
**Website-event requirements:**
- The fields client_user_agent and event_source_url are required for website events. A server webhook does not see the visitor's browser, so capture the user agent in the browser at checkout (see the code sketch).
- event_time must be Unix seconds, and the event must be at most 7 days old. One stale event can fail a whole request, so don't replay old webhooks blindly.
**Consent and data minimization:**
- Send identifiers only where your consent setup and privacy policy allow it. Meta's guidance on match quality assumes the lawful permissions and consents required.
- Hashing doesn't anonymize data. Hashing is pseudonymization, not anonymization: a hashed email is still tied to a person, and consent and data-protection obligations still apply.
**Match quality:** Event Match Quality (EMQ) is Meta's score out of 10 for how effectively the customer information your server sends can match an event to a Meta account. Sending more parameters, correctly hashed, is how you raise it.
## 5. Shopify setup path: native channel versus custom
**Native Facebook & Instagram channel:**
- Shopify's Facebook & Instagram sales channel sends server-side events to Meta once you set customer data sharing to the maximum level, and it handles the SHA-256 hashing and the browser/server deduplication for you.
- Setup path: in your Shopify admin, go to Sales Channels > Facebook & Instagram, link your Meta account, and enable the Conversion API under Data Sharing Settings.
- Data sharing: select Enhanced or Maximum in Shopify's data sharing settings. Some vendor guides say Maximum is required, so choose Maximum to match the fullest identifier set.
- Data access: Meta recommends enabling Always On to help ensure the most reliable performance.
- **Limits:** The native integration sends a fixed set of events with a fixed set of parameters. You can't add a custom event, you can't send Meta your own value field, and you can't push offline conversions.
**Custom implementation (custom pixel plus orders/paid webhook plus your own CAPI sender):**
- Reliable custom setups pair a custom pixel for behavioral events with an orders/paid webhook for purchases, deduplicated by order ID.
- Cost: you need your own path to the Conversions API, such as a Shopify Flow trigger into a small private app or a server-side tag manager container, plus a system access token and a maintenance owner.
- If you go custom, set data sharing to the lowest level if you will run your own CAPI, so Shopify does not send a second server stream.
**Recommendation for a small DTC store such as Cedar & Coil:** use the native channel at launch.
- **Goal served:** a single-product brand needs trustworthy purchase data quickly, with the least maintenance. The native path handles hashing, deduplication, and the four standard events without custom code.
- **Trade-off:** you give up custom parameters and refund or offline events. Build the custom path only if you need those and have someone to maintain it.
**Native setup checklist:**
1. Install the Facebook & Instagram app and connect the Meta Business account.
2. Set data sharing to Maximum (or Enhanced) and data access to Always On.
3. Confirm that Shopify connected a dataset, which Shopify auto-connects to a Facebook Pixel (dataset), and you can verify or update this in Events Manager under Conversions API → Partner Integration → Shopify.
4. Remove any hardcoded Meta pixel from the theme and any other server-side sender tied to the same pixel.
**Code sketch: server-side Purchase (custom path only).** This is a sketch, not production code. It uses Node 18+ with Express and Shopify's `orders/paid` webhook. It assumes the browser has stored `fbp`, `fbc`, and the user agent as cart attributes at checkout. The custom path also needs an idempotency store (`alreadySent` and `markSent`) that you implement.
```javascript
// meta-capi-purchase.mjs (sketch)
import crypto from 'node:crypto';
const API_VERSION = process.env.META_API_VERSION; // confirm the current version in Meta's docs
const PIXEL_ID = process.env.META_PIXEL_ID; // same pixel the browser lane uses
const ACCESS_TOKEN = process.env.META_CAPI_TOKEN; // system-user token, server-side only
const TEST_CODE = process.env.META_TEST_EVENT_CODE; // staging only; unset in production
const SHOPIFY_SECRET = process.env.SHOPIFY_CLIENT_SECRET;
const sha256 = (v) => crypto.createHash('sha256').update(v, 'utf8').digest('hex');
const normEmail = (e) => e.trim().toLowerCase();
const normPhone = (p) => p.replace(/\D/g, ''); // assumes E.164 input (+ and country code)
// 1) Verify the webhook came from Shopify (HMAC over the raw body).
export function isFromShopify(rawBody, hmacHeader) {
const digest = crypto.createHmac('sha256', SHOPIFY_SECRET).update(rawBody).digest('base64');
const a = Buffer.from(digest), b = Buffer.from(hmacHeader || '');
return a.length === b.length && crypto.timingSafeEqual(a, b);
}
// 2) Build the Purchase event. event_id must equal the browser eventID for this order.
export function buildPurchase(order, attrs = {}) {
const orderId = String(order.id); // normalize to the numeric order ID
const contents = order.line_items.map((li) => ({
id: String(li.product_id), // must match the catalog id
quantity: li.quantity,
item_price: Number(li.price),
}));
const user_data = {};
if (order.email) user_data.em = [sha256(normEmail(order.email))];
if (order.phone) user_data.ph = [sha256(normPhone(order.phone))];
if (attrs.fbp) user_data.fbp = attrs.fbp; // not hashed
if (attrs.fbc) user_data.fbc = attrs.fbc; // not hashed
if (attrs.userAgent) user_data.client_user_agent = attrs.userAgent; // required for website events
return {
event_name: 'Purchase',
event_time: Math.floor(new Date(order.processed_at).getTime() / 1000),
event_id: orderId,
action_source: 'website',
event_source_url: `${process.env.STORE_ORIGIN}/`, // a page on your verified domain
user_data,
custom_data: {
currency: order.currency, // ISO 4217
value: Number(order.total_price), // same definition as the browser lane
content_type: 'product',
content_ids: contents.map((c) => c.id),
contents,
num_items: contents.reduce((n, c) => n + c.quantity, 0),
order_id: orderId,
},
};
}
// 3) Send it.
export async function sendPurchase(order, attrs) {
const body = { data: [buildPurchase(order, attrs)], access_token: ACCESS_TOKEN };
if (TEST_CODE) body.test_event_code = TEST_CODE;
const res = await fetch(`https://graph.facebook.com/${API_VERSION}/${PIXEL_ID}/events`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(body),
});
if (!res.ok) throw new Error(`CAPI ${res.status}: ${await res.text()}`);
return res.json();
}
// Webhook route (Express): verify, skip duplicates, send.
// app.post('/webhooks/orders-paid', express.raw({ type: 'application/json' }), async (req, res) => {
// if (!isFromShopify(req.body, req.get('X-Shopify-Hmac-Sha256'))) return res.status(401).end();
// const order = JSON.parse(req.body.toString('utf8'));
// if (await alreadySent(String(order.id))) return res.status(200).end();
// const attrs = Object.fromEntries((order.note_attributes ?? []).map((a) => [a.name, a.value]));
// await sendPurchase(order, { fbp: attrs.fbp, fbc: attrs.fbc, userAgent: attrs.user_agent });
// await markSent(String(order.id));
// res.status(200).end();
// });
```
Check these details before going live:
- Shopify's checkout event may return the order ID in a different format from the webhook. Normalize both to the same string and verify the match in Test Events.
- Test traffic uses `test_event_code` only in staging.
## 6. End-to-end validation before scaling spend
**Step 1: Confirm the event shape in Test Events.** Send events with a test code, then send a server request with the test_event_code parameter and confirm it appears. Remember that you should remove test_event_code from the production payload before you turn the server send on.
**Step 2: Confirm both lanes and deduplication for each event.** Check that each event shows up from both Browser and Server with one of them deduplicated. Confirm the browser and server events share the same ID. Trigger the same action in the browser and confirm the pixel event shows the same event name and the same event ID as the server event.
**Step 3: Place a real test order.** A real test order is the most reliable check. Compare the Meta event with the Shopify order for the order ID, value, currency, content_ids, and num_items. Limit tests to a low-value order you can refund, or use a development store.
**Step 4: Stress test the browser-blocking case.** Test with a content blocker and a private window. The browser copy may disappear while the server copy still arrives. This is the resilience you're building for.
**Step 5: Check match quality.** Meta scores Event Match Quality out of 10 and its documentation treats a rating of Good or Great as optimal. Vendor sources set different targets, such as a 6.0 or higher threshold, so use Meta's own labels and track the trend. Also purchases in Ads Manager far above your actual orders are a warning sign.
**Step 6: Reconcile over a closed window.** Compare Shopify paid orders with deduplicated Meta Purchases for the same closed dates. Expect differences, because attribution and modeling differ from order records, but investigate large gaps order by order. Test a few days of organic orders before any campaign traffic.
**Gates before scaling spend:**
- [ ] Every event type shows browser and server copies, with a matching event ID and event name.
- [ ] Purchase value, currency, content_ids, and num_items match the Shopify order.
- [ ] No duplicate Purchases appear for a single order.
- [ ] Event Match Quality is reviewed for Purchase, and gaps are addressed.
- [ ] Consent tests pass (Section 7).
- [ ] Reconciliation over a closed window shows no unexplained gaps.
- [ ] The test code is removed from production.
Passing these gates confirms the tracking works. It does not prove that any ad drove a sale. An event in Test Events does not prove campaign attribution.
## 7. Consent and compliance note
This is a technical summary, not legal advice. Have counsel review your consent flow before launch.
- **Shopify's consent signals:** The Customer Privacy API tracks four consent signals: analytics, marketing, preferences, and sale_of_data.
- **Shopify's native Meta channel depends on the API:** The Meta channel uses Shopify's web pixel manager, which checks the API for consent state, but only if the Customer Privacy API is enabled. On a fresh Shopify install with the cookie banner toggle off, Meta Pixel fires PageView immediately, before any consent action. Verify the banner settings before launch.
- **Custom pixels have defaults:** By default, new custom pixels require Marketing and Analytics permissions.
- **Server events follow the same settings:** Shopify states that server pixels are still subject to your store's customer privacy and consent settings. Gate the server-side Purchase send on the same consent state as the browser pixel, unless counsel confirms a different basis.
- **Manual scripts are a risk:** Pasting a Meta Pixel or Google Ads tag straight into the theme, with nothing to block it, sets _fbp and _gcl_au cookies on every page load without consent.
- **Regional requirements:** Shopify's analytics cookie, marketing cookie, and marketing pixels such as _fbp need consent in the EU and UK.
- **Data-use terms:** Facebook will use this data for the purposes described in its Business Tools Terms, including ads attribution and ads delivery optimization. Update your privacy policy to describe the data you send to Meta.
- **Campaign status:** keep ads in draft, make no performance claims, and make no attribution-recovery promises until real data exists.
## Source conflicts and open items
- **Data-sharing tier:** Meta's help page says Enhanced or Maximum, while some vendor guides say Maximum only. Confirm the option in your Shopify admin.
- **Tier naming:** Depending on when you installed the app, the lowest level may be labelled Conservative instead of Standard.
- **EMQ thresholds:** vendor targets vary, so use Meta's labels.
- **Purchase value definition:** decide total versus subtotal and document the choice.
- **Meta API version and Shopify order ID format:** verify both against current documentation during build.