# Draft: Meta Conversion Tracking Implementation Guide for Cedar & Coil
**Goal:** measure the Arc Clip Lamp funnel on Shopify reliably enough to optimize Meta ads while remaining resilient to browser-side loss. Use a single Meta dataset/pixel and a clean, documented event taxonomy. Do **not** install multiple Meta pixels or let multiple tools send the same event unless you have intentionally designed deduplication.
## 1. Recommended architecture: Meta Pixel + Conversions API
### Recommended design
Use both:
1. **Browser Meta Pixel**
Sends browser-side events from the Shopify storefront and checkout:
- `ViewContent`
- `AddToCart`
- `InitiateCheckout`
- `Purchase`
2. **Server-side Meta Conversions API (CAPI)**
Sends a server-confirmed version of the same important conversion actions—at minimum `Purchase`—to the **same Meta pixel/dataset**.
3. **Deduplication key shared by both copies**
When the same customer action is sent by both browser and server, give both events the same:
- `event_name`
- `event_id`
### Why use both
The browser Pixel provides the immediate on-site behavioral trail: product views, cart adds, checkout starts, source URL, and browser identifiers such as `_fbp` and `_fbc` when available. However, browser events can be limited by ad blockers, browser privacy controls, network failures, or a shopper leaving before the confirmation page finishes loading.
CAPI sends events from Cedar & Coil’s server environment, so it is not dependent on a browser successfully delivering the event. It is especially valuable for a confirmed `Purchase`, because the server can use the final Shopify order record rather than a page-load signal. It does **not** replace the Pixel: server events alone lose useful browser/session context and funnel behavior. The intended design is redundant event delivery with correct deduplication, not two separate conversion counts. ([help.shopify.com](https://help.shopify.com/en/manual/promoting-marketing/analyze-marketing/meta-data-sharing))
### Practical baseline for this store
For a small Shopify DTC store, use:
| Funnel stage | Browser Pixel | CAPI |
|---|---:|---:|
| `ViewContent` | Yes | Optional initially |
| `AddToCart` | Yes | Optional initially |
| `InitiateCheckout` | Yes | Optional initially |
| `Purchase` | Yes | Yes, server-confirmed |
This preserves the full funnel while making the business-critical purchase event more resilient.
---
## 2. Standard events and required payloads
Use Meta’s **standard event names** exactly. For every event, keep product identifiers consistent with the IDs in the Meta catalog. If the catalog uses Shopify variant IDs, send Shopify variant IDs everywhere; do not send a product handle on one event and SKU on another.
Shopify’s Meta integration automatically supports the four key browser events: product view, add to cart, checkout initiation, and purchase. ([help.shopify.com](https://help.shopify.com/en/manual/promoting-marketing/analyze-marketing/meta-data-sharing))
### Event schema
| Meta event | Fire when | Key parameters |
|---|---|---|
| `ViewContent` | The Arc Clip Lamp product page is viewed | `content_ids`, `content_type`, `content_name`, `value`, `currency` |
| `AddToCart` | A shopper successfully adds the item to cart—not merely clicks a button | `content_ids`, `contents`, `content_type`, `value`, `currency` |
| `InitiateCheckout` | The shopper enters or starts checkout | `content_ids`, `contents`, `content_type`, `value`, `currency`, `num_items` |
| `Purchase` | Shopify confirms checkout/order completion | `content_ids`, `contents`, `content_type`, `value`, `currency`, `order_id` |
For CAPI events, also send the general event fields:
- `event_name`
- `event_time` — Unix timestamp in seconds for when the action occurred
- `event_id` — required for paired Pixel/CAPI deduplication
- `action_source: "website"`
- `event_source_url` where available
- `user_data`
- `custom_data` containing the commerce payload
Meta documents `value` as numeric, `currency` as an ISO 4217 three-letter code such as `USD`, and supports `content_ids`, `contents`, `content_type`, `order_id`, and `num_items`. ([github.com](https://github.com/facebookincubator/Facebook-Server-Side-API-Swagger/blob/main/server-side-api.yaml))
### Recommended event payloads
#### `ViewContent`
```js
fbq("track", "ViewContent", {
content_ids: ["SHOPIFY_VARIANT_ID"],
content_type: "product",
content_name: "Arc Clip Lamp",
value: 68.00,
currency: "USD"
}, { eventID });
```
Use the active selected variant’s identifier and price. If Cedar & Coil adds variants later, send the exact selected variant ID—not a generic product identifier—unless the catalog is intentionally configured around product-group IDs.
#### `AddToCart`
```js
fbq("track", "AddToCart", {
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"
}, { eventID });
```
Fire only after Shopify has accepted the cart addition. This matters for quick-add buttons, out-of-stock states, and cart drawers that can fail or be interrupted.
#### `InitiateCheckout`
```js
fbq("track", "InitiateCheckout", {
content_ids: ["SHOPIFY_VARIANT_ID"],
content_type: "product",
contents: [
{ id: "SHOPIFY_VARIANT_ID", quantity: 1, item_price: 68.00 }
],
value: 68.00,
currency: "USD",
num_items: 1
}, { eventID });
```
Use the cart total at the moment checkout begins. `num_items` is specifically supported for `InitiateCheckout`. ([github.com](https://github.com/facebookincubator/Facebook-Server-Side-API-Swagger/blob/main/server-side-api.yaml))
#### `Purchase`
```js
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 });
```
For the server copy of `Purchase`, use Shopify’s final order data:
- final paid/order total
- final order currency
- actual line items and quantities
- Shopify order ID
- final discounts, shipping, taxes, and duties according to the store’s selected order-total convention
Shopify notes that its Meta order-value events use the order total, including item prices, duties, taxes, and discounts. Whichever convention Cedar & Coil uses, the Pixel and CAPI copies must use the **same** value and currency for the same order. ([help.shopify.com](https://help.shopify.com/en/manual/promoting-marketing/analyze-marketing/meta-data-sharing))
---
## 3. Exactly how Pixel/CAPI deduplication works
### The matching rule
For a browser event and a server event to be treated as the same conversion, send:
- the same Meta pixel/dataset
- the same `event_name`
- the same `event_id`
Example for order `gid://shopify/Order/1234567890`:
```text
event_name: Purchase
event_id: purchase:gid://shopify/Order/1234567890
```
The browser Pixel `Purchase` and the CAPI `Purchase` must both use that exact string.
Meta’s documented deduplication uses matching event name and event ID. Matching events received within 48 hours are considered duplicates, and the later copy is discarded for counting. ([github.com](https://github.com/facebookincubator/Facebook-Server-Side-API-Swagger/blob/main/server-side-api.yaml))
### What **not** to do
- **Do not** generate one random ID in the browser and a different random ID on the server.
- **Do not** use the same `event_id` for different customer actions.
- **Do not** send `Purchase` through the Shopify Meta channel, GTM, a theme snippet, and a custom CAPI endpoint simultaneously.
- **Do not** use the order ID as the ID for `AddToCart` or `InitiateCheckout`; those actions occur before an order exists.
- **Do not** change an event ID during retries. Retries must reuse the original ID.
### Recommended event-ID patterns
| Event | Event ID pattern |
|---|---|
| `ViewContent` | `vc:<pageview-or-uuid>` |
| `AddToCart` | `atc:<cart-line-id-or-uuid>` |
| `InitiateCheckout` | `ic:<checkout-id>` |
| `Purchase` | `purchase:<shopify-order-global-id>` |
For paired CAPI and Pixel events, the ID needs to be generated once and made available to both delivery paths. For `Purchase`, use a deterministic ID derived from the Shopify order ID. Shopify Web Pixels exposes the order ID on `checkout_completed`, making this feasible in a custom implementation. ([shopify.dev](https://shopify.dev/docs/api/web-pixels-api/standard-events/checkout_started?utm_source=openai))
### Separate Meta deduplication from Cedar & Coil’s own idempotency
Implement an internal event ledger as well:
```text
unique key: meta_pixel_id + event_name + event_id
status: queued | sent | accepted | retrying | failed
```
That ledger prevents Cedar & Coil’s job runner or webhook processor from repeatedly sending the same event. Meta-side deduplication is a safety net, not a reason to allow uncontrolled duplicate processing.
---
## 4. Preparing customer information for server-side events
CAPI uses `user_data` to help Meta match a server event to the appropriate person or browser. Send only information Cedar & Coil legitimately collected and is permitted to use for this purpose.
### Send these where available
**Hashed identifiers:**
- `em` — email
- `ph` — phone
- `fn` — first name
- `ln` — last name
- `ct` — city
- `st` — state/region
- `zp` — ZIP/postcode
- `country` — two-letter country code
- `external_id` — stable Cedar & Coil customer identifier, if used consistently
**Raw browser/request identifiers:**
- `fbp` — Meta browser ID from `_fbp`
- `fbc` — Meta click ID from `_fbc`, or derived from `fbclid` where permitted
- `client_ip_address`
- `client_user_agent`
Meta’s API schema specifies SHA-256 hashing for contact and address identifiers such as email, phone, first/last name, city, state, ZIP, and country. It specifies `fbc`, `fbp`, IP address, and user agent as separate fields; do not SHA-256 hash those browser/request values. ([github.com](https://github.com/facebookincubator/Facebook-Server-Side-API-Swagger/blob/main/server-side-api.yaml))
### Normalization rules before SHA-256
Perform normalization **before** hashing:
| Field | Normalize before hashing |
|---|---|
| Email | Trim whitespace; lowercase |
| Phone | Digits only; include country code, e.g. `14155551212` |
| First/last name | Trim; lowercase |
| City | Lowercase; remove spaces and punctuation |
| State | Lowercase state/region code where applicable |
| Country | Lowercase ISO two-letter code, e.g. `us` |
| ZIP | Use the applicable standard postal-code format |
| External ID | Use a stable identifier consistently; hash if that is Cedar & Coil’s chosen convention |
Example:
```js
import crypto from "node:crypto";
const sha256 = (value) =>
crypto.createHash("sha256").update(value, "utf8").digest("hex");
const normalizedEmail = order.email.trim().toLowerCase();
const normalizedPhone = order.phone.replace(/\D/g, "");
const userData = {
em: [sha256(normalizedEmail)],
ph: normalizedPhone ? [sha256(normalizedPhone)] : undefined,
fbp: browserContext.fbp, // not hashed
fbc: browserContext.fbc, // not hashed
client_ip_address: browserContext.ip, // not hashed
client_user_agent: browserContext.userAgent // not hashed
};
```
### Data-handling rules
- Hash identifiers on Cedar & Coil’s server; do not expose the CAPI access token in theme code, a custom pixel, or a browser request.
- Retrieve final commerce values from Shopify’s server-side order data. Do not trust a browser-posted price, quantity, email, or order total as authoritative.
- Keep the `fbp`, `fbc`, IP, user agent, event source URL, and consent state captured at the time of the shopper session where possible.
- Avoid sending empty strings, placeholders, or fabricated data.
- Restrict access to raw customer data and logs; redact personal data from debug logging.
---
## 5. Shopify setup path: native Meta channel vs. custom implementation
## Option A — Shopify’s native Facebook & Instagram by Meta sales channel
### What it provides
Shopify’s native channel installs and manages the Meta Pixel and provides data-sharing levels:
- **Standard:** browser Pixel
- **Enhanced:** browser Pixel plus CAPI purchase event
- **Maximum:** browser Pixel plus CAPI purchase event and Meta’s latest advertising technology
Shopify documents that the browser Pixel automatically tracks `ViewContent`, `AddToCart`, `InitiateCheckout`, and `Purchase`; its Enhanced and Maximum settings add server-to-server CAPI for `Purchase`. ([help.shopify.com](https://help.shopify.com/en/manual/promoting-marketing/analyze-marketing/meta-data-sharing))
### Setup steps
1. In Shopify Admin, install or open **Facebook & Instagram by Meta** under **Sales channels**.
2. Connect the correct Meta business portfolio, ad account, catalog, and **one** Meta pixel/dataset.
3. Go to:
- **Sales channels → Facebook & Instagram → Settings → Data sharing settings**
4. Enable customer data sharing.
5. Choose **Enhanced** or **Maximum** only after Cedar & Coil’s consent configuration and privacy notice are ready.
6. Connect the selected Meta pixel.
7. Publish the Arc Clip Lamp to the Facebook & Instagram sales channel so its Shopify product/variant identifiers align with the Meta catalog.
8. Remove any duplicate Meta Pixel code from:
- `theme.liquid`
- Shopify Online Store Preferences
- GTM containers
- old tracking apps
- agency-installed snippets
Shopify specifically warns that retaining manually installed Meta Pixel code after connecting the sales channel can create duplicate or incorrect reporting. ([help.shopify.com](https://help.shopify.com/en/manual/promoting-marketing/analyze-marketing/meta-pixel))
### Advantages
- Fastest, lowest-maintenance path.
- Shopify manages checkout compatibility.
- Native catalog sync helps keep event product IDs aligned to catalog products.
- Provides Pixel funnel events and CAPI purchase coverage without Cedar & Coil handling a Meta access token or building a CAPI service.
### Limitations
- Shopify’s documented native CAPI coverage is specifically the `Purchase` event; it is not the same as a fully custom server-side implementation of every funnel stage.
- Cedar & Coil has less control over payload shaping, enrichment, logging, retry behavior, and event-routing rules.
- It is not the right option if a technical team needs a first-party event warehouse, custom order-status rules, subscriptions, offline conversions, or CAPI delivery for all funnel events.
## Option B — Custom Pixel + custom CAPI service
### What it entails
A custom implementation generally includes:
1. A Shopify **web pixel** subscribing to standard customer events:
- `product_viewed`
- `product_added_to_cart`
- `checkout_started`
- `checkout_completed`
2. Browser-side Meta Pixel calls using Shopify event payloads rather than DOM scraping.
3. A Cedar & Coil server endpoint or queue for CAPI.
4. A verified Shopify order webhook or Admin API lookup to enrich and validate the completed order before sending the server `Purchase`.
5. An event-ID strategy that joins browser and server copies.
Shopify Web Pixels provide access to storefront, checkout, and post-purchase customer events, and Shopify recommends Web Pixels rather than legacy DOM scraping for analytics implementations. ([shopify.dev](https://shopify.dev/docs/apps/build/marketing/pixels))
### Advantages
- Full control over event payloads, event IDs, customer-data preparation, retries, and observability.
- Can send CAPI for all four events if justified.
- Can create a first-party tracking ledger and reconcile CAPI requests against Shopify orders.
- Better fit for a larger stack or nonstandard checkout/order logic.
### Risks and costs
- More engineering and QA.
- Requires secure storage and rotation of Meta access tokens.
- Requires webhook verification, retry handling, consent gating, and a customer-data policy.
- Requires careful checkout-extensibility compatibility and ongoing maintenance.
- A custom pixel runs in Shopify’s sandbox; code should use Shopify’s provided customer event payloads rather than assuming ordinary top-frame browser/DOM access. ([shopify.dev](https://shopify.dev/docs/apps/build/marketing/pixels))
## Recommendation for Cedar & Coil
**Start with Shopify’s native Facebook & Instagram by Meta sales channel using Enhanced or Maximum data sharing, subject to valid consent and privacy configuration.**
That is the recommended small-store baseline because it produces the required browser funnel events and adds server-side purchase delivery without custom infrastructure. Do **not** layer a custom `Purchase` CAPI service on top of it for the same pixel unless the exact deduplication design has been tested.
Move to a custom implementation only if Cedar & Coil has a clear requirement that the native channel cannot meet—for example, server-side delivery of non-purchase funnel events, custom event transformations, a warehouse-backed measurement system, or special order flows.
### Code sketch: custom server-side `Purchase` request
This is illustrative for a **fully custom** build, not something to add alongside the native Shopify Meta channel.
```js
import crypto from "node:crypto";
const META_PIXEL_ID = process.env.META_PIXEL_ID;
const META_CAPI_TOKEN = process.env.META_CAPI_TOKEN;
const META_API_VERSION = process.env.META_API_VERSION; // keep current in deployment config
const sha256 = (value) =>
crypto.createHash("sha256").update(value, "utf8").digest("hex");
async function sendPurchaseToMeta({ shopifyOrder, browserContext, testEventCode }) {
// Use the same deterministic ID used by the browser Pixel Purchase call.
// Example browser event ID:
// purchase:gid://shopify/Order/1234567890
const eventId = `purchase:${shopifyOrder.admin_graphql_api_id}`;
const lineItems = shopifyOrder.line_items.map((line) => ({
id: String(line.variant_id), // Must match the Meta catalog ID strategy
quantity: line.quantity,
item_price: Number(line.price)
}));
const userData = {};
if (shopifyOrder.email) {
userData.em = [sha256(shopifyOrder.email.trim().toLowerCase())];
}
if (shopifyOrder.phone) {
const digits = shopifyOrder.phone.replace(/\D/g, "");
if (digits) userData.ph = [sha256(digits)];
}
// Capture these during the browser session, subject to consent.
if (browserContext?.fbp) userData.fbp = browserContext.fbp;
if (browserContext?.fbc) userData.fbc = browserContext.fbc;
if (browserContext?.ip) userData.client_ip_address = browserContext.ip;
if (browserContext?.userAgent) {
userData.client_user_agent = browserContext.userAgent;
}
const body = {
data: [{
event_name: "Purchase",
event_time: Math.floor(
new Date(shopifyOrder.processed_at).getTime() / 1000
),
event_id: eventId,
action_source: "website",
event_source_url: browserContext?.eventSourceUrl,
user_data: userData,
custom_data: {
currency: shopifyOrder.currency,
value: Number(shopifyOrder.total_price),
content_type: "product",
content_ids: lineItems.map((line) => line.id),
contents: lineItems,
order_id: String(shopifyOrder.id)
}
}],
...(testEventCode ? { test_event_code: testEventCode } : {})
};
const response = await fetch(
`https://graph.facebook.com/${META_API_VERSION}/${META_PIXEL_ID}/events?access_token=${META_CAPI_TOKEN}`,
{
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(body)
}
);
if (!response.ok) {
throw new Error(`Meta CAPI error: ${response.status} ${await response.text()}`);
}
return response.json();
}
```
In production, place this behind a queue and retry policy, verify Shopify webhook signatures, look up the authoritative order server-side, retain the original `event_id` on retries, and log Meta’s response without logging raw customer details. Meta’s CAPI schema requires `event_name`, `event_time`, `user_data`, and `action_source`; it supports `test_event_code` for test events. ([github.com](https://github.com/facebookincubator/Facebook-Server-Side-API-Swagger/blob/main/server-side-api.yaml))
---
## 6. Validate end to end before scaling spend
Do not judge campaign performance until the event implementation passes a controlled test.
### A. Preflight checks
- [ ] One intended Meta pixel/dataset is connected.
- [ ] No legacy Pixel snippet remains in theme code or GTM.
- [ ] The Arc Clip Lamp is available in the Meta catalog.
- [ ] Event `content_ids` match the catalog’s item-ID strategy.
- [ ] Browser `Purchase` and server `Purchase` use the same `event_id` if using custom CAPI.
- [ ] The server has a persistent idempotency/event ledger.
- [ ] Consent behavior has been tested for the intended markets.
### B. Run a full test journey
Use a Shopify test payment method or a controlled internal order:
1. Visit the Arc Clip Lamp product page.
2. Confirm exactly one `ViewContent`.
3. Add the lamp to cart.
4. Confirm exactly one `AddToCart`.
5. Start checkout.
6. Confirm exactly one `InitiateCheckout`.
7. Complete checkout.
8. Confirm:
- one browser `Purchase`
- one server `Purchase`, if CAPI is enabled
- the same `event_name` and `event_id` on the paired custom implementation
- a final value, currency, line items, and order ID matching Shopify
### C. Use Meta Events Manager
In Events Manager:
- Use **Test Events** while implementing custom CAPI.
- Add the Test Events code as `test_event_code` to CAPI requests.
- Inspect browser and server arrivals separately.
- Confirm the paired purchase is marked as deduplicated rather than counted twice.
- Review diagnostics for missing `value`, `currency`, `content_ids`, user data, or event-match-quality issues.
Meta’s API supports a `test_event_code` for server-event validation, and Meta’s documentation directs implementers to test that paired browser/server events are received and deduplicated correctly. ([github.com](https://github.com/facebookincubator/Facebook-Server-Side-API-Swagger/blob/main/server-side-api.yaml))
### D. Reconcile after launch
For the same date range and timezone:
- Compare Shopify paid orders and gross sales to internal event logs.
- Confirm each paid order produces no more than one accepted server-side `Purchase` in Cedar & Coil’s event ledger.
- Confirm duplicate server retries are not creating extra CAPI sends.
- Compare Meta-reported purchases to Shopify orders as a directional measurement check—not as an expectation of one-to-one equality. Consent choices, browser constraints, attribution windows, and platform reporting rules will cause differences.
Do not promise or plan around a fixed attribution-recovery percentage. Treat CAPI as a resilience and data-quality layer whose real effect must be measured in Cedar & Coil’s own implementation.
---
## 7. Consent and compliance note
This is an implementation guide, not legal advice. Cedar & Coil should have counsel review its practices for the jurisdictions it targets.
### Operating rules
1. **Honor consent before marketing tracking where required.**
Do not fire the Meta Pixel or send CAPI marketing data for a visitor who has not granted required consent or who has opted out.
2. **Make the privacy notice specific.**
Explain that Cedar & Coil uses Meta business tools, including browser and server-side conversion measurement, and describe the categories of data shared and the purpose: advertising measurement, attribution, and ad optimization.
3. **Use Shopify’s customer-privacy controls.**
Shopify Web Pixels can be configured with customer privacy settings, and Shopify’s pixel framework can defer execution until consent is available in consent-required regions. ([shopify.dev](https://shopify.dev/docs/apps/build/marketing/pixels))
4. **Send only necessary, lawfully collected customer information.**
Hash matching fields properly, protect access tokens and raw customer data, set retention limits, and do not use data fields unrelated to advertising measurement.
5. **Respect opt-outs and applicable data-processing rules.**
Build consent state into the event pipeline—not merely the browser tag. A server webhook may know an order was paid, but that does not automatically mean Cedar & Coil may send that shopper’s information to Meta for ad measurement.
6. **Keep one source of truth for configuration.**
Document the selected data-sharing level, pixel ID, catalog ID strategy, consent logic, event schema, and owner for changes. This reduces accidental duplicate tracking when agencies, apps, or theme updates are introduced later.
Shopify emphasizes that merchants control how customer information is shared through Meta data-sharing settings and are responsible for keeping their privacy policy current. ([help.shopify.com](https://help.shopify.com/en/manual/promoting-marketing/analyze-marketing/meta-data-sharing))