# Cedar & Coil: Shopify-to-Meta Conversion Tracking Guide
**Objective:** Reliably measure the Arc Clip Lamp purchase funnel despite browser privacy restrictions. No campaign has launched, so the immediate goal is implementation quality—not performance optimization.
## 1. Recommended architecture
Use both:
1. **Browser-side Meta Pixel**
2. **Server-side Meta Conversions API (CAPI)**
3. **A shared event ID for deduplication**
```text
Shopify storefront ── Meta Pixel ───────────────┐
├── Meta dataset/pixel
Shopify server/order data ── Conversions API ──┘
Same event name + ID
```
### Why both are needed
**Meta Pixel provides browser context**, including:
- Product and cart activity as it happens
- Page URL and referrer context
- Meta browser and click identifiers (`_fbp` and `_fbc`)
- Fast event delivery for audience building and campaign optimization
However, browser events can be lost because of:
- Ad blockers
- Browser tracking restrictions
- Cookie expiration
- JavaScript failures
- Customers closing the confirmation page before a Purchase event fires
**Conversions API provides a server-side path** that does not depend on the Meta script completing in the customer’s browser. It is particularly valuable for `Purchase`, where Shopify’s paid order should be the source of truth.
CAPI is not a way to bypass consent. Server events must follow the same privacy and consent rules as their browser equivalents.
### Recommended source of truth
| Event | Browser source | Server source |
|---|---|---|
| `ViewContent` | Shopify `product_viewed` | Optional first-party event forwarding |
| `AddToCart` | Shopify `product_added_to_cart` | Optional first-party event forwarding |
| `InitiateCheckout` | Shopify `checkout_started` | Optional first-party event forwarding |
| `Purchase` | Shopify `checkout_completed` | Shopify paid-order event/webhook |
For a small DTC store, Cedar & Coil should use Shopify’s native **Facebook & Instagram by Meta** sales channel. It manages the Pixel, CAPI connection, customer-data matching, and deduplication with much less operational risk than a custom implementation.
---
## 2. Standard events and parameters
Use Meta’s standard event names exactly as written.
### Common event-level fields
Server events should include:
- `event_name`
- `event_time`: Unix timestamp in seconds
- `event_id`: unique identifier used for deduplication
- `action_source`: `"website"`
- `event_source_url`: the relevant storefront or checkout URL
- `user_data`: permissible customer and browser identifiers
- `custom_data`: product and monetary information
For multi-currency orders, send the amount and currency actually presented to the customer. Do not convert every order to USD unless that is also Shopify’s reporting basis.
### `ViewContent`
**Trigger:** Arc Clip Lamp product page is viewed.
**Key parameters:**
```json
{
"content_ids": ["<META_CATALOG_ITEM_ID>"],
"content_type": "product",
"content_name": "Arc Clip Lamp",
"value": 68.00,
"currency": "USD"
}
```
Use the exact item ID found in the connected Meta catalog. Depending on the catalog configuration, this may be a variant ID or a transformed Shopify retailer ID. Do not assume the Shopify product ID is automatically correct.
### `AddToCart`
**Trigger:** A customer adds the Arc Clip Lamp to the cart.
**Key parameters:**
```json
{
"content_ids": ["<META_CATALOG_ITEM_ID>"],
"content_type": "product",
"contents": [
{
"id": "<META_CATALOG_ITEM_ID>",
"quantity": 1,
"item_price": 68.00
}
],
"value": 68.00,
"currency": "USD"
}
```
For multiple units, `value` should equal the value added by that action, and `quantity` should reflect the actual quantity.
### `InitiateCheckout`
**Trigger:** The customer begins checkout.
**Key parameters:**
```json
{
"content_ids": ["<META_CATALOG_ITEM_ID>"],
"content_type": "product",
"contents": [
{
"id": "<META_CATALOG_ITEM_ID>",
"quantity": 1,
"item_price": 68.00
}
],
"num_items": 1,
"value": 68.00,
"currency": "USD"
}
```
Use the current checkout value after product discounts. Document whether the value excludes or includes tax and shipping, then apply that rule consistently.
### `Purchase`
**Trigger:** Shopify confirms the order was paid—not merely that the thank-you page loaded.
**Required measurement parameters:**
```json
{
"content_ids": ["<META_CATALOG_ITEM_ID>"],
"content_type": "product",
"contents": [
{
"id": "<META_CATALOG_ITEM_ID>",
"quantity": 1,
"item_price": 68.00
}
],
"value": 68.00,
"currency": "USD",
"order_id": "<SHOPIFY_ORDER_ID>"
}
```
For orders containing multiple products or variants:
- Include every purchased catalog ID in `content_ids`.
- Include each line item in `contents`.
- Use the actual quantity and post-discount item price.
- Send the order’s actual presentment currency.
- Use a documented value definition that can be reproduced from Shopify.
A practical value definition is **product subtotal after discounts, excluding tax and shipping**. If Cedar & Coil instead wants Meta ROAS based on the total charged, use that consistently and reconcile against the corresponding Shopify field.
---
## 3. Exactly how Pixel–CAPI deduplication works
If the same customer action is sent through both the browser and server, Meta needs to recognize that the two messages represent one event.
Meta’s recommended deduplication key consists of:
1. The same event name:
- Browser: `Purchase`
- Server: `Purchase`
2. The same event identifier:
- Browser Pixel option: `eventID`
- Server CAPI field: `event_id`
3. Both events sent to the same Meta dataset/pixel
Example browser event:
```javascript
const eventId = "purchase_584739201";
fbq(
"track",
"Purchase",
{
value: 68.00,
currency: "USD",
content_ids: ["<META_CATALOG_ITEM_ID>"],
content_type: "product"
},
{
eventID: eventId
}
);
```
Matching server event:
```json
{
"event_name": "Purchase",
"event_id": "purchase_584739201"
}
```
When Meta receives the matching browser and server events within its deduplication window, it retains one conversion rather than counting two.
### Event-ID rules
- Generate one ID per real customer action.
- Reuse that ID only for the matching browser event, server event, and legitimate server retries.
- Never create a new Purchase ID merely because a webhook is retried.
- Do not reuse one ID across `AddToCart`, `InitiateCheckout`, and `Purchase`.
- Treat names and IDs as exact, case-sensitive values.
- Avoid putting email addresses or other personal information into an event ID.
For Purchase, a stable ID derived from Shopify’s immutable order ID is appropriate:
```text
purchase_<canonical-shopify-order-id>
```
For earlier funnel events, generate a UUID in the storefront event handler and pass the same UUID to the server if a server copy is sent.
If Cedar & Coil uses Shopify’s native Meta channel, let the integration own this process. Adding a second manually installed Pixel or another CAPI app can defeat deduplication and cause double counting.
---
## 4. Preparing customer information for server-side events
CAPI uses customer information to match Shopify events to Meta accounts. Prepare it carefully and only when consent and applicable law permit it.
### Contact fields to hash
Common fields include:
- `em`: email
- `ph`: phone
- `fn`: first name
- `ln`: last name
- `ct`: city
- `st`: state or region
- `zp`: postal code
- `country`: country
- `external_id`: a stable first-party customer ID
For each applicable field:
1. Retrieve it from the authoritative Shopify order/customer record.
2. Apply Meta’s field-specific normalization.
3. Encode the normalized value as UTF-8.
4. Hash it with SHA-256.
5. Send the lowercase hexadecimal hash.
6. Do not add a salt.
7. Do not hash an already hashed value again.
Examples of normalization:
- **Email:** trim surrounding whitespace and lowercase it.
- **Phone:** include the country code and remove spaces, punctuation, and other non-digit formatting.
- **Names and addresses:** trim and lowercase, then follow Meta’s field-specific punctuation and formatting rules.
- **Country:** use the normalized two-letter country code where available.
### Fields that must not be hashed
Send these in their original expected format:
- `client_ip_address`
- `client_user_agent`
- `fbp`
- `fbc`
`fbp` is derived from Meta’s browser identifier. `fbc` represents a Meta click identifier and should only be sent when it was legitimately captured from an `fbclid` or existing `_fbc` value. Never fabricate either one.
When possible, capture `_fbp`, `_fbc`, the user agent, and relevant page URL first-party during the session and associate them with the checkout. Do this only after the applicable consent state allows it.
Hashing is a transport requirement for matching fields; it does **not** make the processing anonymous or remove consent obligations.
---
## 5. Concrete Shopify setup path
### Option A: Native Facebook & Instagram by Meta channel
Typical Shopify path:
1. In Shopify Admin, open **Sales channels**.
2. Add or open **Facebook & Instagram by Meta**.
3. Complete the channel’s Meta business-asset setup.
4. Open the channel’s **Settings**.
5. Find **Share data** or **Customer data sharing**.
6. Select the intended Meta dataset/pixel.
7. Choose a sharing level that uses both Pixel and CAPI:
- **Standard:** browser Pixel only; not recommended for this requirement.
- **Enhanced:** Pixel plus Conversions API.
- **Maximum:** Pixel plus Conversions API and additional supported matching technology/data sharing.
8. Align the selected level with Cedar & Coil’s consent configuration and privacy disclosures.
9. Remove any old theme-installed Meta Pixel, duplicate custom pixel, or competing CAPI app.
Shopify changes labels periodically, but the settings remain within the Meta channel’s data-sharing area.
### Option B: Custom implementation
A custom setup normally requires:
- A Shopify app pixel using the Web Pixels/Customer Events API
- Subscriptions to Shopify events such as:
- `product_viewed`
- `product_added_to_cart`
- `checkout_started`
- `checkout_completed`
- A secure server endpoint
- A verified Shopify paid-order webhook
- A queue with retries and dead-letter handling
- An idempotency store keyed by Shopify order ID
- Storage or propagation of the consent state and browser event ID
- Meta token rotation and secret management
- Catalog-ID mapping
- Ongoing monitoring as Shopify and Meta APIs change
Do not use an unverified webhook body. Validate Shopify’s webhook signature before reading or forwarding customer or order information.
### Comparison and recommendation
| Consideration | Native Meta channel | Custom implementation |
|---|---|---|
| Pixel + CAPI | Built in | Must be engineered |
| Deduplication | Managed by Shopify/Meta | Must be exact |
| Checkout compatibility | Platform maintained | Must follow Shopify APIs |
| Catalog-ID alignment | Usually automatic | Custom mapping required |
| Control over payload | Limited | High |
| Observability | Moderate | Potentially high |
| Maintenance burden | Low | High |
| Best fit | Small and midsize DTC stores | Complex stacks or strict custom requirements |
**Recommendation:** Use the native channel with **Enhanced or Maximum** sharing, subject to the store’s consent and legal basis. Cedar & Coil does not currently have a requirement that justifies owning a custom CAPI pipeline.
### Server-side Purchase request sketch
The following illustrates the custom path. It assumes the Shopify webhook has already passed HMAC verification and that the order, tracking context, and consent state are legitimate.
```javascript
import crypto from "node:crypto";
const sha256 = (value) =>
crypto
.createHash("sha256")
.update(String(value), "utf8")
.digest("hex");
const clean = (value) =>
value == null || value === "" ? undefined : value;
const hashEmail = (email) =>
clean(email) ? sha256(email.trim().toLowerCase()) : undefined;
const hashPhone = (phone) => {
if (!clean(phone)) return undefined;
const normalized = String(phone).replace(/\D/g, "");
return normalized ? sha256(normalized) : undefined;
};
const hashText = (value) =>
clean(value) ? sha256(String(value).trim().toLowerCase()) : undefined;
const compact = (object) =>
Object.fromEntries(
Object.entries(object).filter(([, value]) => value !== undefined)
);
// This mapping must return the exact ID used by the connected Meta catalog.
// Do not assume a raw Shopify variant ID unless the catalog confirms it.
function metaCatalogId(lineItem, catalogMap) {
const id = catalogMap[String(lineItem.variant_id)];
if (!id) {
throw new Error(`No Meta catalog ID for variant ${lineItem.variant_id}`);
}
return id;
}
export async function sendMetaPurchase({
order,
tracking,
catalogMap,
testEventCode
}) {
const orderId = String(order.id);
const eventId = `purchase_${orderId}`;
const contents = order.line_items.map((item) => ({
id: metaCatalogId(item, catalogMap),
quantity: Number(item.quantity),
item_price: Number(item.price)
}));
const contentIds = contents.map((item) => item.id);
const userData = compact({
em: hashEmail(order.email) ? [hashEmail(order.email)] : undefined,
ph: hashPhone(order.phone) ? [hashPhone(order.phone)] : undefined,
fn: hashText(order.billing_address?.first_name)
? [hashText(order.billing_address.first_name)]
: undefined,
ln: hashText(order.billing_address?.last_name)
? [hashText(order.billing_address.last_name)]
: undefined,
ct: hashText(order.billing_address?.city)
? [hashText(order.billing_address.city)]
: undefined,
st: hashText(order.billing_address?.province_code)
? [hashText(order.billing_address.province_code)]
: undefined,
zp: hashText(order.billing_address?.zip)
? [hashText(order.billing_address.zip)]
: undefined,
country: hashText(order.billing_address?.country_code)
? [hashText(order.billing_address.country_code)]
: undefined,
external_id: order.customer?.id
? [sha256(String(order.customer.id))]
: undefined,
// Do not hash these fields.
client_ip_address:
tracking.clientIp ?? order.client_details?.browser_ip,
client_user_agent:
tracking.userAgent ?? order.client_details?.user_agent,
fbp: tracking.fbp,
fbc: tracking.fbc
});
const event = {
event_name: "Purchase",
event_time: Math.floor(
new Date(order.processed_at ?? order.created_at).getTime() / 1000
),
event_id: eventId,
action_source: "website",
event_source_url:
tracking.eventSourceUrl ?? process.env.SHOPIFY_STORE_URL,
user_data: userData,
custom_data: {
content_ids: contentIds,
content_type: "product",
contents,
// Example uses Shopify's current subtotal after discounts.
// Confirm this field against the webhook schema and reporting policy.
value: Number(
order.current_subtotal_price ?? order.subtotal_price
),
currency: order.presentment_currency ?? order.currency,
order_id: orderId
}
};
const body = {
data: [event],
...(testEventCode ? { test_event_code: testEventCode } : {})
};
const url = new URL(
`https://graph.facebook.com/v${process.env.META_GRAPH_VERSION}/` +
`${process.env.META_PIXEL_ID}/events`
);
url.searchParams.set("access_token", process.env.META_CAPI_TOKEN);
const response = await fetch(url, {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify(body)
});
const result = await response.json();
if (!response.ok) {
throw new Error(`Meta CAPI rejected Purchase: ${JSON.stringify(result)}`);
}
return { eventId, result };
}
```
Production requirements not fully shown above:
- Keep the Meta token in server-side secret storage.
- Do not log access tokens or unhashed customer fields.
- Verify the Shopify webhook signature.
- Enforce the stored consent state before sending.
- Queue events and retry transient failures.
- Reuse the same `event_id` on every retry.
- Record Meta’s response and failure reason.
- Remove `test_event_code` after validation.
- Confirm the chosen Meta Graph API version is currently supported.
---
## 6. End-to-end validation before scaling spend
Do not rely on seeing one green status indicator. Validate the complete funnel.
### A. Audit for duplicate installations
Before testing:
- Search the Shopify theme for old `fbq` code.
- Check Shopify **Customer events** for custom Meta pixels.
- Check Google Tag Manager for another Meta Pixel.
- Check installed apps for another CAPI or Meta tracking integration.
- Confirm only one intended dataset/pixel receives production events.
### B. Use Meta Test Events
In Meta Events Manager:
1. Select the Cedar & Coil dataset/pixel.
2. Open **Test events**.
3. Start a test browser session.
4. For custom CAPI events, add the displayed `test_event_code` to the request.
5. Exercise the full flow:
- View the Arc Clip Lamp
- Add it to the cart
- Begin checkout
- Complete a Shopify test purchase
Use Shopify’s test-payment facilities rather than a real charge.
### C. Verify every event’s payload
For each event, inspect:
- Correct standard event name
- Browser, server, or both connection methods as intended
- Correct `content_ids`
- Catalog ID resolves to the Arc Clip Lamp item or variant
- Correct quantity and item price
- Correct value and presentment currency
- `Purchase.order_id` matches the Shopify test order
- Event timestamp is plausible
- `action_source` is `website`
- No personal information appears in URLs or `custom_data`
### D. Verify deduplication
For a test Purchase:
- Browser `eventID` and server `event_id` must match exactly.
- Both must use `Purchase`.
- Events Manager should identify browser and server copies as deduplicated.
- Meta should report one Purchase, not two.
- Refreshing the order-status page must not create another unique Purchase.
- Replaying the webhook must reuse the same event ID and remain one Purchase.
If two Purchases appear, the most likely causes are:
- Mismatched event IDs
- Browser event has no `eventID`
- Different event names
- Different datasets/pixels
- A second Pixel or CAPI integration
- A new ID generated on every webhook retry
### E. Test privacy and failure conditions
Run separate tests for:
- Chrome and Safari
- Mobile and desktop
- Customer grants advertising consent
- Customer declines advertising consent
- Browser Pixel is unavailable or blocked
- Slow checkout or delayed webhook
- Order-status page refresh
- Webhook retry
The expected behavior must follow the store’s consent policy. A declined advertising consent should not be “recovered” by silently sending the same marketing event server-side.
### F. Reconcile against Shopify
For the test period, compare:
- Unique paid Shopify order IDs
- Unique server-side Meta Purchase event IDs
- Purchase values and currencies
- Browser/server deduplication results
- Failed or retried webhook deliveries
Every eligible paid test order should map to one stable Meta Purchase event. Investigate discrepancies before increasing spend.
Also review Events Manager for:
- Diagnostics warnings
- Event Match Quality and missing-parameter guidance
- Deduplication status
- Catalog-ID matching
- Browser/server event coverage
Event Match Quality is a diagnostic, not a goal to maximize by collecting unnecessary customer data.
---
## 7. Consent and compliance
Cedar & Coil should treat Pixel and CAPI as two delivery paths for the same advertising processing—not as separate consent regimes.
Implementation requirements:
- Configure Shopify’s customer privacy settings or a compatible consent-management platform.
- Gate browser advertising events according to the customer’s consent state.
- Pass that consent state to the server and apply it before CAPI delivery.
- Do not use CAPI to circumvent a rejected cookie or advertising choice.
- Update the privacy and cookie disclosures to explain Meta advertising measurement and matching.
- Collect and transmit only fields required for the documented purpose.
- Never send sensitive information, payment data, passwords, or personal information inside URLs or custom event fields.
- Restrict access to Shopify customer data and the Meta access token.
- Establish appropriate retention and deletion procedures.
- Honor applicable access, deletion, opt-out, and “do not sell/share” rights.
- Review regional requirements—including prior consent where required in the EU and UK—with qualified privacy counsel.
### Official implementation references
- [Shopify: Facebook data sharing](https://help.shopify.com/en/manual/promoting-marketing/analyze-marketing/meta-data-sharing)
- [Shopify: Meta Pixel](https://help.shopify.com/en/manual/promoting-marketing/analyze-marketing/meta-pixel)
- [Shopify Web Pixels API](https://shopify.dev/docs/api/web-pixels-api)
- [Shopify `checkout_completed` event](https://shopify.dev/docs/api/web-pixels-api/standard-events/checkout_completed)
- [Meta: Conversions API](https://developers.facebook.com/docs/marketing-api/conversions-api/)
- [Meta: Deduplicating Pixel and server events](https://developers.facebook.com/docs/marketing-api/conversions-api/deduplicate-pixel-and-server-events/)
- [Meta: Customer information parameters](https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/customer-information-parameters/)
- [Meta Pixel event reference](https://developers.facebook.com/docs/meta-pixel/reference/)