# Draft implementation guide — Cedar & Coil Shopify-to-Meta tracking
**Objective:** Track the Arc Clip Lamp purchase funnel reliably despite browser privacy controls, without double-counting conversions.
## 1. Recommended architecture
Use the same Meta Pixel/dataset through two complementary paths:
```text
Shopper browser
└─ Meta Pixel → Meta
ViewContent
AddToCart
InitiateCheckout
Purchase
Shopify / Cedar & Coil server
└─ Conversions API → Meta
Purchase at minimum
Other funnel events when implemented reliably
Meta
└─ Deduplicates matching browser and server events
```
### Why both are needed
**The browser Meta Pixel provides:**
- Immediate product and checkout behavior.
- Browser identifiers such as `_fbp` and `_fbc`.
- Page URL, user agent, and other browser context useful for matching and attribution.
However, browser events can be lost because of ad blockers, privacy restrictions, failed page loads, or customers closing a page before the request finishes.
**Conversions API provides:**
- A server-to-server path that browser ad blockers cannot directly block.
- An authoritative Purchase signal based on a paid Shopify order.
- Controlled retries, logging, and monitoring.
The server may lack browser identifiers unless they were captured earlier, and CAPI is **not** a way to bypass consent. The best design therefore sends both signals when permitted and deduplicates them. Shopify’s Enhanced and Maximum data-sharing levels combine the Pixel with CAPI; Shopify currently documents the server-to-server component specifically for Purchase. ([help.shopify.com](https://help.shopify.com/en/manual/promoting-marketing/analyze-marketing/meta-data-sharing))
### Recommended scope
- Send all four funnel events through the browser.
- Send **Purchase through CAPI at minimum**.
- In a custom implementation, mirror the upper-funnel events through CAPI only if Cedar & Coil can assign matching event IDs and reliably transport the events to its server.
- Do not promise or plan around a particular attribution-recovery percentage.
---
## 2. Standard events and parameters
Shopify exposes corresponding customer events for product views, additions to cart, checkout starts, and completed checkouts. ([shopify.dev](https://shopify.dev/docs/api/web-pixels-api/standard-events))
| Meta event | Shopify trigger | Key parameters |
|---|---|---|
| `ViewContent` | `product_viewed` | `content_ids`, `content_type`, `contents`, `content_name`, `value`, `currency` |
| `AddToCart` | `product_added_to_cart` | `content_ids`, `content_type`, `contents`, `value`, `currency` |
| `InitiateCheckout` | `checkout_started` | `content_ids`, `content_type`, `contents`, `num_items`, `value`, `currency` |
| `Purchase` | Browser: `checkout_completed`; server: paid-order webhook | **`content_ids`, `content_type`, `contents`, `num_items`, `value`, `currency`**, optionally `order_id` |
Shopify’s own custom Meta pixel example maps `product_viewed`, `product_added_to_cart`, `checkout_started`, and `checkout_completed` to these Meta standard events. ([help.shopify.com](https://help.shopify.com/en/manual/promoting-marketing/pixels/custom-pixels/code?locale=fr))
### `ViewContent`
Send when the Arc Clip Lamp product detail page is viewed.
```json
{
"content_ids": ["<META_CATALOG_RETAILER_ID>"],
"content_type": "product",
"content_name": "Arc Clip Lamp",
"contents": [
{
"id": "<META_CATALOG_RETAILER_ID>",
"quantity": 1,
"item_price": 68.00
}
],
"value": 68.00,
"currency": "USD"
}
```
Use the selected Shopify variant’s identifier if the Meta catalog is variant-based. The `content_ids` value must use the same identifier format as the corresponding item’s retailer ID in the Meta catalog.
### `AddToCart`
Send after Shopify confirms the item was added, not merely when the button was clicked.
```json
{
"content_ids": ["<META_CATALOG_RETAILER_ID>"],
"content_type": "product",
"contents": [
{
"id": "<META_CATALOG_RETAILER_ID>",
"quantity": 1,
"item_price": 68.00
}
],
"value": 68.00,
"currency": "USD"
}
```
For quantity two, `quantity` should be `2` and `value` should be the line total, such as `136.00`, before any applicable cart-level adjustment.
### `InitiateCheckout`
Send when checkout actually starts.
```json
{
"content_ids": [
"<META_CATALOG_RETAILER_ID>"
],
"content_type": "product",
"contents": [
{
"id": "<META_CATALOG_RETAILER_ID>",
"quantity": 1,
"item_price": 68.00
}
],
"num_items": 1,
"value": 68.00,
"currency": "USD"
}
```
Use the checkout’s current total and currency. Include every checkout line, not just the Arc Clip Lamp’s first line.
### `Purchase`
Send only after a successful completed or paid order.
```json
{
"content_ids": [
"<META_CATALOG_RETAILER_ID>"
],
"content_type": "product",
"contents": [
{
"id": "<META_CATALOG_RETAILER_ID>",
"quantity": 1,
"item_price": 68.00
}
],
"num_items": 1,
"value": 68.00,
"currency": "USD",
"order_id": "<SHOPIFY_ORDER_ID>"
}
```
**Do not hardcode `$68` for Purchase.** Use the order’s actual final total and transaction currency so quantities, discounts, shipping, duties, and taxes are represented consistently. Shopify’s Pixel integration uses checkout total price for events carrying order value. ([help.shopify.com](https://help.shopify.com/en/manual/promoting-marketing/analyze-marketing/meta-data-sharing))
### Content-ID rule
Choose one canonical ID scheme and use it everywhere:
1. Meta catalog retailer ID.
2. Browser Pixel `content_ids`.
3. CAPI `custom_data.content_ids`.
4. Every `contents[].id`.
Do not send a Shopify product ID from the browser, a variant ID from CAPI, and an SKU in the catalog. Although all three describe the product, Meta will not necessarily recognize them as the same catalog item.
---
## 3. Exactly how Pixel/CAPI deduplication works
For every action sent through both channels:
1. Create one unique `event_id`.
2. Send it through the Pixel as `eventID`.
3. Send the identical value through CAPI as `event_id`.
4. Use the exact same, case-sensitive `event_name`.
5. Send both to the same Meta Pixel/dataset ID.
6. Deliver them reasonably close together.
Meta’s recommended deduplication method treats events sent to the same Pixel ID within 48 hours with matching `event_name` and `event_id` as duplicates and discards the later copy. ([storage.googleapis.com](https://storage.googleapis.com/lr-tech-docs-resources/PDFs/Conversions-API-Direct-Integration-Playbook_English.pdf?utm_source=openai))
### Browser syntax
```js
const eventId = `cedar-coil:purchase:${shopifyOrderGid}`;
fbq(
'track',
'Purchase',
{
value: orderValue,
currency: orderCurrency,
content_ids: contentIds,
content_type: 'product',
contents
},
{
eventID: eventId
}
);
```
### Server syntax
```json
{
"event_name": "Purchase",
"event_id": "cedar-coil:purchase:gid://shopify/Order/123456789"
}
```
Notice the different property names:
- Pixel: `eventID`
- CAPI: `event_id`
### Recommended Purchase ID
Shopify’s `checkout_completed` event exposes the resulting order ID, while an order webhook provides the corresponding order identity server-side. ([shopify.dev](https://shopify.dev/docs/api/web-pixels-api/standard-events/checkout_completed?utm_source=openai))
Use an immutable value such as:
```text
cedar-coil:purchase:<SHOPIFY_ORDER_GID>
```
For example:
```text
cedar-coil:purchase:gid://shopify/Order/123456789
```
The browser can construct this from:
```js
event.data.checkout.order.id
```
The server can construct it from the order webhook’s corresponding GraphQL order ID, commonly `admin_graphql_api_id`.
### Important rules
- Generate an ID **per event**, not per customer, browser, or session.
- A different AddToCart action needs a different ID.
- Page refreshes and delivery retries must reuse the original Purchase ID.
- CAPI retries must reuse the same payload and `event_id`.
- `_fbp`, `_fbc`, email, and phone improve user matching but are not substitutes for the recommended `event_name` + `event_id` deduplication key.
- Deduplication discards a redundant event; do not assume Meta combines the best fields from both copies. Make each event as complete as practical.
- If the Pixel sends `Purchase` and CAPI sends `purchase`, or the IDs differ by even one character, the pair will not deduplicate.
---
## 4. Preparing customer information server-side
CAPI’s `user_data` should contain only customer information Cedar & Coil is permitted to process and share.
### Normalize, then hash
Personally identifiable matching fields should be:
1. Normalized according to Meta’s rules.
2. UTF-8 encoded.
3. SHA-256 hashed.
4. Sent as lowercase hexadecimal hashes.
Typical hashed fields include:
- `em`: email
- `ph`: phone
- `fn`: first name
- `ln`: last name
- `ct`: city
- `st`: state
- `zp`: ZIP/postal code
- `country`: country code
- `external_id`: Cedar & Coil or Shopify customer identifier
Meta’s official Business SDK can normalize and SHA-256-hash customer-information fields automatically, reducing implementation errors. ([github.com](https://github.com/facebook/facebook-nodejs-business-sdk/blob/main/README.md?utm_source=openai))
At minimum:
```js
normalizedEmail = email.trim().toLowerCase();
normalizedPhone = phone.replace(/\D/g, ""); // retain country code
```
Do not send empty strings, `"null"`, `"undefined"`, placeholder phone numbers, or hashes of missing values.
### Do not hash these fields
Send the following in their original format:
- `client_ip_address`
- `client_user_agent`
- `fbc`
- `fbp`
Meta’s integration guidance distinguishes these browser/network fields from customer fields that require hashing. ([storage.googleapis.com](https://storage.googleapis.com/lr-tech-docs-resources/PDFs/Conversions-API-Direct-Integration-Playbook_English.pdf?utm_source=openai))
### Capture browser identifiers before the webhook
A Shopify paid-order webhook originates from Shopify—not from the customer’s browser. Therefore:
- Do not use the webhook request’s IP address as `client_ip_address`.
- Do not use the webhook request’s user-agent as `client_user_agent`.
- Capture `_fbp`, `_fbc`, customer browser IP, and browser user-agent during the storefront or checkout session when permitted.
- Associate that context with the Shopify checkout token or order ID.
- Retrieve it when processing the paid-order webhook.
- If a value was never captured, omit it rather than fabricating it.
Shopify Web Pixels can read top-frame cookies through `browser.cookie.get()` and can forward event data to a first-party endpoint with `fetch(..., {keepalive: true})`. ([shopify.dev](https://shopify.dev/docs/api/web-pixels-api/standard-api/browser?utm_source=openai))
### Security and data handling
- Keep the CAPI access token exclusively server-side.
- Never expose it in theme code, a custom pixel, or a tag manager.
- Encrypt sensitive stored data and limit retention.
- Avoid putting customer information in `event_id`, `order_id`, URLs, or `custom_data`.
- Hashing matching fields does not make the underlying processing anonymous or remove consent obligations.
---
## 5. Concrete Shopify setup path
## Option A: Native Facebook and Instagram by Meta sales channel
### Setup
1. In Shopify, install or open **Facebook & Instagram** under Sales channels.
2. Connect the correct Meta business portfolio, Page, ad account, catalog, and Pixel/dataset.
3. Go to:
- **Sales channels**
- **Facebook & Instagram**
- **Settings**
- **Data sharing settings**
4. Enable customer data sharing.
5. Choose **Maximum**, provided Cedar & Coil’s consent and privacy configuration supports that level.
6. Connect the intended Meta Pixel.
7. Complete the product-catalog sync and verify that the Arc Clip Lamp’s retailer ID matches reported `content_ids`.
Shopify documents that Standard uses the browser Pixel, while Enhanced and Maximum use both the Pixel and CAPI. Maximum also receives updates to Meta’s current advertising integration. ([help.shopify.com](https://help.shopify.com/en/manual/promoting-marketing/analyze-marketing/meta-data-sharing))
### Remove competing implementations
Before testing:
- Remove any old Meta Pixel code from `theme.liquid`.
- Remove any Pixel ID configured under obsolete Online Store preferences.
- Disable duplicate Meta tags in Google Tag Manager.
- Disable other apps sending the same events to the same Pixel.
Shopify specifically warns that leaving manually installed Pixel code in place can produce duplicate or incorrect reporting. ([help.shopify.com](https://help.shopify.com/en/manual/promoting-marketing/analyze-marketing/meta-pixel?utm_source=openai))
### Advantages
- Lowest implementation and maintenance burden.
- Pixel, catalog, and CAPI configuration are managed as a partner integration.
- Good fit for a standard Shopify checkout and a small product catalog.
- Less risk of exposing access tokens or mishandling webhook retries.
### Limitations
- Less control over payload construction and event IDs.
- Less application-level logging and replay control.
- Shopify currently documents the CAPI part of Enhanced and Maximum specifically as sending Purchase; upper-funnel server coverage may not be equivalent to a custom dual-channel implementation. ([help.shopify.com](https://help.shopify.com/en/manual/promoting-marketing/analyze-marketing/meta-data-sharing))
### Recommendation for Cedar & Coil
**Use the native Facebook and Instagram by Meta sales channel with Maximum data sharing, subject to the store’s consent and legal settings.**
For a small DTC store selling the Arc Clip Lamp, its lower engineering risk outweighs the benefits of owning a custom CAPI service. Verify the resulting browser/server connection and deduplication in Events Manager rather than installing a second implementation “for backup.”
Use a custom implementation only when Cedar & Coil has a defined requirement the native integration cannot satisfy.
---
## Option B: Custom Shopify Pixel plus CAPI service
A custom build is appropriate when Cedar & Coil needs:
- Explicit control of every `event_id`.
- Server-side upper-funnel events.
- First-party logs and alerting.
- Custom catalog-ID mapping.
- More sophisticated consent logic.
- Integration with additional warehouse, subscription, or CRM events.
### Components
1. **Shopify Web Pixel app extension**
- Subscribe to `product_viewed`.
- Subscribe to `product_added_to_cart`.
- Subscribe to `checkout_started`.
- Subscribe to `checkout_completed`.
- Fire the browser Meta Pixel.
- Forward consented event context to Cedar & Coil’s backend.
2. **Backend event service**
- Validate incoming requests.
- Normalize and hash customer information.
- Queue CAPI events.
- Retry transient failures without changing `event_id`.
- Store Meta response codes without logging tokens or unhashed PII.
3. **Shopify `orders/paid` webhook**
- Verify the Shopify HMAC before processing.
- Enqueue a Purchase event.
- Use the order’s immutable ID for deduplication.
- Make webhook handling idempotent.
Shopify supports Web Pixel extensions for its standard customer events and an `orders/paid` webhook for paid orders. Access to email, phone, name, and address fields can require protected-customer-data approval. ([shopify.dev](https://shopify.dev/docs/apps/build/marketing/build-web-pixels?utm_source=openai))
Shopify also advises merchants to prefer available app pixels for stability, security, and performance before building an unsupported custom pixel. ([help.shopify.com](https://help.shopify.com/en/manual/promoting-marketing/pixels/custom-pixels/code?locale=fr))
### Server-side Purchase request sketch
The following is an illustrative Node.js request. As of August 31, 2026, Meta Business SDK v26 corresponds to Graph API v26; production code should pin a supported version and upgrade it deliberately. ([github.com](https://github.com/facebook/facebook-nodejs-business-sdk/releases?after=v3.0.0&utm_source=openai))
```js
import crypto from "node:crypto";
const PIXEL_ID = process.env.META_PIXEL_ID;
const ACCESS_TOKEN = process.env.META_CAPI_ACCESS_TOKEN;
const TEST_EVENT_CODE = process.env.META_TEST_EVENT_CODE;
// Use only if the Meta catalog's retailer IDs are Shopify variant IDs.
// Otherwise replace this with Cedar & Coil's real catalog-ID mapping.
function metaContentId(lineItem) {
return String(lineItem.variant_id);
}
function sha256(value) {
return crypto
.createHash("sha256")
.update(value, "utf8")
.digest("hex");
}
function normalizeEmail(value) {
return value.trim().toLowerCase();
}
function normalizePhone(value) {
return value.replace(/\D/g, "");
}
export async function sendMetaPurchase(order, browserContext = {}) {
const orderGid =
order.admin_graphql_api_id ||
`gid://shopify/Order/${order.id}`;
// Must exactly match the browser Pixel's eventID.
const eventId = `cedar-coil:purchase:${orderGid}`;
// Prefer presentment money so the server currency matches checkout currency.
const totalMoney =
order.current_total_price_set?.presentment_money || {
amount: order.current_total_price || order.total_price,
currency_code:
order.presentment_currency || order.currency
};
const contents = order.line_items
.filter(line => line.variant_id)
.map(line => {
const unitMoney =
line.price_set?.presentment_money || {
amount: line.price
};
return {
id: metaContentId(line),
quantity: Number(line.quantity),
item_price: Number(unitMoney.amount)
};
});
const email = order.email;
const phone =
order.phone ||
order.shipping_address?.phone ||
order.billing_address?.phone;
const userData = {};
if (email) {
userData.em = [sha256(normalizeEmail(email))];
}
if (phone) {
const normalized = normalizePhone(phone);
if (normalized) userData.ph = [sha256(normalized)];
}
if (order.customer?.id) {
userData.external_id = [
sha256(String(order.customer.id))
];
}
// These must describe the customer browser—not the Shopify webhook call.
const clientIp =
browserContext.clientIpAddress || order.browser_ip;
const clientUserAgent =
browserContext.clientUserAgent ||
order.client_details?.user_agent;
if (clientIp) {
userData.client_ip_address = clientIp;
}
if (clientUserAgent) {
userData.client_user_agent = clientUserAgent;
}
// Send fbp/fbc un-hashed and only when actually captured.
if (browserContext.fbp) userData.fbp = browserContext.fbp;
if (browserContext.fbc) userData.fbc = browserContext.fbc;
const eventTime = Math.floor(
new Date(
order.processed_at || order.created_at
).getTime() / 1000
);
const event = {
event_name: "Purchase",
event_time: eventTime,
event_id: eventId,
action_source: "website",
event_source_url:
browserContext.eventSourceUrl ||
"https://YOUR_STORE_DOMAIN/",
user_data: userData,
custom_data: {
value: Number(totalMoney.amount),
currency: totalMoney.currency_code,
content_ids: contents.map(item => item.id),
content_type: "product",
contents,
num_items: contents.reduce(
(sum, item) => sum + item.quantity,
0
),
order_id: String(order.id)
}
};
const payload = { data: [event] };
// Include only while validating in Meta Test Events.
if (TEST_EVENT_CODE) {
payload.test_event_code = TEST_EVENT_CODE;
}
const endpoint =
`https://graph.facebook.com/v26.0/${PIXEL_ID}/events` +
`?access_token=${encodeURIComponent(ACCESS_TOKEN)}`;
// Never log endpoint: it contains the access token.
const response = await fetch(endpoint, {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(payload)
});
const result = await response.json();
if (!response.ok) {
throw new Error(
`Meta CAPI rejected Purchase ${eventId}: ` +
JSON.stringify(result)
);
}
return { eventId, result };
}
```
For production:
- Put webhook work on a queue.
- Store a record keyed by `event_id`.
- Retry network errors and appropriate server errors with the same payload.
- Do not generate a new event ID on retry.
- Do not mark an event delivered until Meta returns a successful API response.
- Redact access tokens and raw customer information from logs.
- Prefer Meta’s maintained Business SDK or parameter-builder tooling for complete name and address normalization. Meta’s official SDK includes CAPI request classes and normalization/hashing support. ([github.com](https://github.com/facebook/facebook-nodejs-business-sdk/blob/main/README.md?utm_source=openai))
---
## 6. End-to-end validation before scaling spend
No campaign has launched, so validation should use controlled test sessions and test orders rather than assumed performance data.
### A. Preflight audit
Confirm:
- One Meta Pixel/dataset is connected.
- One implementation owns each event.
- No old theme Pixel remains.
- No duplicate GTM Meta tags remain.
- No other Shopify app sends the same events to the same dataset.
- The Arc Clip Lamp’s catalog retailer ID matches the ID the events will send.
- Production and test environments cannot accidentally share the same live dataset.
### B. Test the browser funnel
With marketing consent granted where required:
1. Open the Arc Clip Lamp product page.
2. Confirm one `ViewContent`.
3. Add one lamp to the cart.
4. Confirm one `AddToCart`.
5. Start checkout.
6. Confirm one `InitiateCheckout`.
7. Place a test order.
8. Confirm browser `Purchase`.
9. Confirm server `Purchase`.
10. Confirm both Purchase copies use the same event name and event ID.
Use both Shopify Pixel Helper and Meta Events Manager/Test Events. Shopify Pixel Helper displays subscribed customer events and their data in real time. ([help.shopify.com](https://help.shopify.com/en/manual/promoting-marketing/pixels/custom-pixels/testing?utm_source=openai))
For each event, inspect:
- Event name and connection method.
- `event_id`.
- `value` as a number.
- Three-letter `currency`.
- `content_ids`.
- `contents[].id`, quantity, and item price.
- Event time.
- Event source URL.
- Available matching fields.
- Meta API errors and diagnostics.
### C. Confirm Purchase deduplication
The desired result is:
```text
Browser Purchase
event_name: Purchase
eventID: cedar-coil:purchase:<order-id>
Server Purchase
event_name: Purchase
event_id: cedar-coil:purchase:<order-id>
Meta result:
One deduplicated Purchase
```
If two Purchases remain, check:
- Different Pixel IDs.
- `Purchase` versus `purchase`.
- Different order-ID formats.
- Numeric ID on one side versus Shopify GID on the other.
- Extra whitespace or prefixes.
- Missing `eventID` on the browser call.
- A second browser Pixel or second CAPI integration.
### D. Test failure and privacy cases
Run separate tests for:
- Safari or another privacy-restrictive browser.
- A browser with an ad blocker.
- Browser closed immediately after purchase.
- Marketing consent denied.
- Applicable sale/share opt-out enabled.
- Webhook delivered twice.
- Temporary Meta API failure.
- Missing email or phone.
- Guest checkout.
- Discounted order.
- Quantity greater than one.
- Shipping and tax added.
- Non-default checkout currency, if the store offers it.
With browser blocking, the server Purchase should still be capable of arriving when sharing is lawfully allowed. With consent denied, behavior should follow Cedar & Coil’s configured legal basis and consent rules—not simply send CAPI because the browser Pixel was suppressed.
### E. Reconcile against Shopify
Before increasing spend, compare Meta’s received Purchase events against Shopify’s paid orders for a controlled period.
Review:
- Number of paid production orders.
- Number of received server Purchase events.
- Deduplicated Purchase count.
- Total event value and currency.
- Missing order IDs.
- Duplicate order IDs.
- API failures awaiting retry.
- Test orders excluded from production analysis.
Compare like with like: paid gross orders are not the same as fulfilled orders, net revenue after refunds, or Meta-attributed purchases.
---
## 7. Consent and compliance note
### Shopify consent integration
Configure Meta tracking as marketing/analytics processing and, where applicable, sale or sharing of data. Shopify’s pixel manager can prevent an app pixel from loading until all declared privacy permissions have been granted, and exposes consent states including:
- `analyticsProcessingAllowed`
- `marketingAllowed`
- `saleOfDataAllowed`
([shopify.dev](https://shopify.dev/docs/api/web-pixels-api/pixel-privacy?utm_source=openai))
The same decision must govern server events. The fact that `orders/paid` fired does not automatically establish permission to send the buyer’s data to Meta.
### Operational requirements
Cedar & Coil should:
- Maintain an accurate privacy notice describing Meta data sharing and advertising purposes.
- Honor applicable cookie-consent requirements.
- Honor applicable US state sale/share opt-outs and other data-subject rights.
- Send only the minimum customer information needed.
- Restrict access to tokens and customer data.
- Set and enforce retention periods.
- Support deletion and access requests.
- Apply Meta data-processing restrictions where legally required.
- Document whether the native channel or Cedar & Coil is responsible for each processing step.
Shopify requires apps handling protected customer data to follow data-minimization, transparency, and security requirements; public apps also have mandatory data-request and redaction webhooks. ([shopify.dev](https://shopify.dev/docs/apps/launch/protected-customer-data?utm_source=openai))
This is an implementation guide, not legal advice. Consent behavior should be reviewed for every jurisdiction in which Cedar & Coil sells.