# Shopify → Meta conversion tracking guide
## 1. Recommended architecture: Pixel + Conversions API
Use the **Meta Pixel** for browser events and **Conversions API (CAPI)** for server-side events. The Pixel captures on-site activity and browser signals; CAPI lets Shopify or your backend send confirmed order data directly to Meta, even when a browser tag is blocked or limited by privacy features.
Where the same event is sent by both, deduplicate the pair (see section 3). CAPI changes how data is delivered; it does **not** permit tracking visitors who declined advertising consent.
## 2. Standard events and key parameters
Send these standard Meta event names with consistent product IDs and value rules:
| Event | Fire when | Useful parameters |
|---|---|---|
| `ViewContent` | A product page is viewed | `content_ids`, `content_type: "product"`, `content_name`, `value`, `currency` |
| `AddToCart` | An item is actually added to the cart | `content_ids`, `content_type`, `contents` (ID, quantity, item price), `num_items`, `value`, `currency` |
| `InitiateCheckout` | Checkout begins | `content_ids`, `contents`, `num_items`, `value`, `currency` |
| `Purchase` | An order is confirmed/paid, not merely submitted | `content_ids`, `contents`, `num_items`, `value`, `currency`, plus a stable order reference such as `order_id` |
Use numeric values and a real ISO currency code. Decide whether `value` includes tax and shipping, and apply that rule consistently across browser and server sends. Make `content_ids` match the product or variant IDs in the Meta catalog; don’t mix ID formats.
## 3. Exactly how deduplication works
Meta deduplicates browser and server events using **both** `event_name` and `event_id`.
For one purchase, the Pixel and CAPI must send the exact same event name (including capitalization, e.g. `Purchase`) and the exact same unique event ID. Use a stable per-order ID, such as an ID derived from the Shopify order, and reuse it for that order’s browser and server events. Do not generate two IDs independently or reuse one ID across different orders.
For a custom Pixel implementation, the browser call has this form:
```js
fbq('track', 'Purchase', purchaseParams, { eventID: orderEventId });
```
The CAPI event must use that same `orderEventId` as its `event_id`. A healthy test should show one deduplicated purchase, not two separate conversions. If Shopify’s native channel is sending the purchase, don’t add a second custom CAPI purchase sender; verify the channel’s deduplication in Test Events instead.
## 4. Prepare customer information before server-side sending
- Send only information you are permitted to collect and use for advertising measurement.
- Normalize email by trimming whitespace and lowercasing it; normalize phone to a consistent international format such as E.164.
- SHA-256 hash normalized email and phone before placing them in `user_data`. Hashing is pseudonymization, **not** anonymization.
- Send browser identifiers such as `fbp` and `fbc`, and IP address and user agent, in their expected raw formats when lawfully available and consent permits.
- Keep the access token on the server. Never expose it in storefront JavaScript, page source, or logs.
- Minimize fields to what is needed; don’t send sensitive information.
## 5. Shopify setup: native channel vs. custom implementation
### Recommended for a small DTC store: Shopify’s native Facebook & Instagram channel
In Shopify admin, install/open the **Facebook & Instagram** sales channel, connect the correct Meta business portfolio and dataset, and configure its data-sharing setting. The channel’s **Enhanced** or **Maximum** setting sends purchases through CAPI. Confirm that the right dataset is selected and check which funnel events arrive in Meta.
This is the simplest maintained route for a small store. Let the channel own its Pixel/CAPI purchase pairing, and remove or disable any overlapping theme code, custom pixels, or other tracking apps that send the same events. Don’t rely on legacy Additional Scripts on checkout/order-status pages; Shopify’s supported tracking surfaces are its channel and Customer Events/web pixels.
### Custom implementation
Choose custom only if you need event or data control the native channel doesn’t provide and have someone to own secure webhook handling, retries, monitoring, and deduplication. A typical path is:
1. Use a Shopify web pixel/Customer Events subscription for browser events.
2. Capture permitted browser identifiers and carry them with the order where possible.
3. Receive a Shopify order-paid webhook on your backend; verify Shopify’s webhook signature.
4. Make the send idempotent by order, retry transient failures, and log delivery outcomes.
5. Send the server Purchase to CAPI and pair it with the browser Pixel Purchase using the same event ID.
**Illustrative Node.js request sketch** — replace placeholders, use the current Graph API version, and adapt to your backend. `normalizedEmail` and `normalizedPhone` must be normalized before hashing; the example hashes them server-side.
```js
import { createHash } from "node:crypto";
const sha256 = (value) =>
createHash("sha256").update(value).digest("hex");
const orderEventId = `shopify-order-${order.id}`; // also used by Pixel
const eventTime = Math.floor(new Date(order.paid_at).getTime() / 1000);
const event = {
event_name: "Purchase",
event_time: eventTime,
event_id: orderEventId,
action_source: "website",
event_source_url: "https://YOUR_STORE/product/YOUR_PRODUCT",
user_data: {
em: normalizedEmail ? [sha256(normalizedEmail.trim().toLowerCase())] : undefined,
ph: normalizedPhone ? [sha256(normalizedPhone)] : undefined,
fbp: consentedFbp || undefined,
fbc: consentedFbc || undefined,
client_ip_address: consentedIp || undefined,
client_user_agent: consentedUserAgent || undefined
},
custom_data: {
currency: "ORDER_CURRENCY",
value: Number(orderValue),
content_ids: ["CATALOG_MATCHING_PRODUCT_OR_VARIANT_ID"],
content_type: "product",
contents: [{ id: "CATALOG_MATCHING_PRODUCT_OR_VARIANT_ID",
quantity: 1, item_price: Number(itemPrice) }],
order_id: String(order.id)
}
};
const response = await fetch(
`https://graph.facebook.com/vXX.X/YOUR_DATASET_ID/events?access_token=${process.env.META_CAPI_TOKEN}`,
{
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ data: [event] })
}
);
if (!response.ok) throw new Error(`Meta CAPI failed: ${response.status}`);
```
In production, omit unavailable fields rather than sending `undefined`, use the actual order currency and agreed value basis, and keep the token out of request logs. For Meta’s Test Events workflow, include the test event code in the request while testing.
## 6. Validate end to end before scaling spend
1. Inventory existing Pixel installs and CAPI senders first; remove duplicates rather than layering on another sender.
2. In Meta Events Manager, open the correct dataset’s **Test Events** view. Use a Shopify test order if available; otherwise don’t place a real order just to test without the store owner’s approval.
3. Exercise the product view, add-to-cart, checkout, and purchase flow. Confirm each expected event arrives with the right dataset, event name, value, currency, and item IDs.
4. For Purchase, confirm the browser and server sends use the same `event_name` and `event_id`, and Meta shows the event as deduplicated.
5. Confirm the CAPI response is successful and check Events Manager diagnostics for errors. After changes, allow time for match-quality reporting to update.
6. Repeat a purchase test or verify idempotency so a webhook retry or page refresh can’t count the same order twice. Keep a record of the test order and its expected result.
A Pixel firing in the browser alone is not proof Meta received the event; verify arrival in Events Manager.
## 7. Consent and compliance
Configure the consent banner/CMP before enabling advertising tags or server sends. Only send advertising events and customer identifiers when the applicable consent and legal requirements allow it; honor consent withdrawal and relevant privacy signals. A server-side route must not be used to bypass a visitor’s choice. Check the store’s privacy notice, data-retention practices, Meta terms, and requirements in the regions where the store operates.