Meta Ads — Pixel & Conversions API Official Documentation
CodFlow's tracking stack (Meta Pixel in theme01 + Conversions API in
cod-server) must always match Meta's official behavior. This skill
vendors the official documentation so every change — ours or a
contributor's — can be grounded against the real spec instead of guesses,
blog posts, or AI memory.
Rule for agents and contributors: any tracking change must be verified
against these docs before review. When replying to a tracking PR, read
the relevant reference here first and cite it.
The docs (all unaltered official content, fetched from developers.facebook.com)
Pixel — browser side (fbq())
| File |
What it covers |
references/pixel/pixel-overview.md |
What the Pixel is, redundant setup with CAPI |
references/pixel/pixel-get-started.md |
Installing the base code, the fbq queue |
references/pixel/pixel-reference-standard-events.md |
The standard-event table — exact definitions of Purchase, Lead, InitiateCheckout, etc. + object properties. The source of truth for "which event is this action?" |
references/pixel/pixel-conversion-tracking.md |
Firing events on actions vs page load, purchase-confirmation-page pattern |
references/pixel/pixel-advanced-matching.md |
em, ph etc. customer params on fbq('init') |
references/pixel/pixel-single-page-apps.md |
SPA pitfalls (irrelevant to our full-page loads — know why) |
references/pixel/pixel-custom-audiences.md |
Audience creation from Pixel data |
references/pixel/pixel-gdpr.md |
GDPR/Limited Data Use reasoning |
references/pixel/pixel-data-processing-options.md |
_fbp cookie + data processing options |
Conversions API — server side (/events endpoint)
| File |
What it covers |
references/conversions-api/capi-overview.md |
What CAPI is, redundant setup recommendation |
references/conversions-api/capi-get-started.md |
System user tokens, access, first request |
references/conversions-api/capi-using-the-api.md |
Endpoint mechanics, payloads, batching, error handling |
references/conversions-api/capi-parameters.md |
Parameters index |
references/conversions-api/capi-server-event-parameters.md |
event_name, event_time, event_id, event_source_url, action_source — the per-event field contract |
references/conversions-api/capi-customer-information-parameters.md |
Hashed ph, em, client_ip_address, client_user_agent, fbp, fbc — what we send and how it's normalized |
references/conversions-api/capi-custom-data-parameters.md |
value, currency, contents, content_ids, order_id, num_items |
references/conversions-api/capi-original-event-parameters.md |
Original-event dedup fields (aggregated/merged events) |
references/conversions-api/capi-main-body-parameters.md |
data[], test_event_code wrapper |
references/conversions-api/capi-deduplication.md |
Pixel ↔ CAPI dedup: browser eventID must equal CAPI event_id AND names must match. The rule behind CodFlow's eventID = orderId pattern |
references/conversions-api/capi-best-practices.md |
Meta's recommended architecture, timing, and matching quality guidance |
references/conversions-api/capi-verifying-setup.md |
Events Manager validation, Test Events |
references/conversions-api/capi-offline-events.md |
Offline conversion semantics (delayed events — the category our purchase-on-delivery model lives in) |
references/conversions-api/capi-payload-helper.md |
Meta's interactive payload builder (for debugging shapes) |
How CodFlow maps onto these docs (quick orientation)
- Browser: theme01's
BaseHead.astro loads the canonical fbevents.js
snippet (PageView on load); thank-you.astro fires the conversion event
with { eventID: orderId } — the fourth fbq argument, per the dedup doc.
- Server:
cod-server/src/workflows/capi.ts (Cloudflare Workflow)
sends the mirrored event via /events with event_id: orderId;
capi-helpers.ts gates which status transitions trigger it;
capi_event_log records what was sent (and powers idempotency).
- Config:
store_pixel_config (pixel id, access token, test event
code, conversion event choice, test mode) — Settings → Tracking.
- Dedup contract: browser
eventID === CAPI event_id === orderId,
same event_name on both sides. Any tracking change that breaks this
equality double-counts conversions (see capi-deduplication.md).
- Standard-event semantics: which CodFlow moment maps to which Meta
event is governed by pixel-reference-standard-events.md — notably
Purchase is defined as at-checkout ("lands on thank you or
confirmation page") and Lead as a completed sign-up. COD
purchase-on-delivery is an offline-style delayed Purchase (see
capi-offline-events.md) — legitimate, but it must be a deliberate
merchant choice, not a silent default.
Working rules for tracking changes
- Ground first. Read the relevant reference file(s) above before
writing or reviewing a single line of tracking code. Cite the doc in
the PR/review when a decision hinges on Meta behavior.
- Never break the dedup equality (browser eventID === server
event_id, matching names) — silent double-counting or
double-sending is the #1 tracking bug class.
- A new conversion-event mode must fire from BOTH sides (browser +
CAPI mirror) or from exactly ONE side deliberately, never accidentally.
PR #103's lesson: a mode that exists only in the settings enum is not a
feature.
capi_event_log is the idempotency ledger — anything that can fire
twice (webhook retries, status toggles) must be guarded through it.
- Test Mode (
test_event_code) exists for verification — use
capi-verifying-setup.md's flow before claiming an event works.
- Docs are read-only reference. These files are unaltered Meta
content (only a source header is prepended). Never edit them to match
code — if code and docs disagree, the CODE changes (or Meta did, and
we re-fetch).
Refreshing the docs
Meta updates its docs; when a tracking question can't be answered from
these files (or the content looks outdated), re-fetch with Firecrawl:
firecrawl scrape "https://developers.facebook.com/documentation/<path>" --only-main-content
Keep the source header (URL + fetch date) on every file so staleness is
auditable. Content below the header stays unaltered.
1---2name: meta-ads3description: Official Meta (Facebook) Pixel and Conversions API reference docs for CodFlow's tracking stack — standard events, event parameters, deduplication, advanced matching, test events, and best practices. Use whenever working on Meta Pixel integration, CAPI server events, conversion tracking, event deduplication, attribution, or reviewing PRs that touch tracking (cod-server/src/workflows/capi.ts, capi-helpers.ts, capi_event_log, theme01 pixel scripts, store_pixel_config).4metadata:5 source: https://skillmd.com/skills/bighadj22/meta-ads6---78# Meta Ads — Pixel & Conversions API Official Documentation910CodFlow's tracking stack (Meta Pixel in theme01 + Conversions API in11cod-server) must always match **Meta's official behavior**. This skill12vendors the official documentation so every change — ours or a13contributor's — can be grounded against the real spec instead of guesses,14blog posts, or AI memory.1516**Rule for agents and contributors: any tracking change must be verified17against these docs before review.** When replying to a tracking PR, read18the relevant reference here first and cite it.1920## The docs (all unaltered official content, fetched from developers.facebook.com)2122### Pixel — browser side (`fbq()`)2324| File | What it covers |25|---|---|26| `references/pixel/pixel-overview.md` | What the Pixel is, redundant setup with CAPI |27| `references/pixel/pixel-get-started.md` | Installing the base code, the `fbq` queue |28| `references/pixel/pixel-reference-standard-events.md` | **The standard-event table** — exact definitions of `Purchase`, `Lead`, `InitiateCheckout`, etc. + object properties. The source of truth for "which event is this action?" |29| `references/pixel/pixel-conversion-tracking.md` | Firing events on actions vs page load, purchase-confirmation-page pattern |30| `references/pixel/pixel-advanced-matching.md` | `em`, `ph` etc. customer params on `fbq('init')` |31| `references/pixel/pixel-single-page-apps.md` | SPA pitfalls (irrelevant to our full-page loads — know why) |32| `references/pixel/pixel-custom-audiences.md` | Audience creation from Pixel data |33| `references/pixel/pixel-gdpr.md` | GDPR/Limited Data Use reasoning |34| `references/pixel/pixel-data-processing-options.md` | `_fbp` cookie + data processing options |3536### Conversions API — server side (`/events` endpoint)3738| File | What it covers |39|---|---|40| `references/conversions-api/capi-overview.md` | What CAPI is, redundant setup recommendation |41| `references/conversions-api/capi-get-started.md` | System user tokens, access, first request |42| `references/conversions-api/capi-using-the-api.md` | Endpoint mechanics, payloads, batching, error handling |43| `references/conversions-api/capi-parameters.md` | Parameters index |44| `references/conversions-api/capi-server-event-parameters.md` | **`event_name`, `event_time`, `event_id`, `event_source_url`, `action_source`** — the per-event field contract |45| `references/conversions-api/capi-customer-information-parameters.md` | Hashed `ph`, `em`, `client_ip_address`, `client_user_agent`, `fbp`, `fbc` — what we send and how it's normalized |46| `references/conversions-api/capi-custom-data-parameters.md` | `value`, `currency`, `contents`, `content_ids`, `order_id`, `num_items` |47| `references/conversions-api/capi-original-event-parameters.md` | Original-event dedup fields (aggregated/merged events) |48| `references/conversions-api/capi-main-body-parameters.md` | `data[]`, `test_event_code` wrapper |49| `references/conversions-api/capi-deduplication.md` | **Pixel ↔ CAPI dedup: browser `eventID` must equal CAPI `event_id` AND names must match.** The rule behind CodFlow's eventID = orderId pattern |50| `references/conversions-api/capi-best-practices.md` | Meta's recommended architecture, timing, and matching quality guidance |51| `references/conversions-api/capi-verifying-setup.md` | Events Manager validation, Test Events |52| `references/conversions-api/capi-offline-events.md` | Offline conversion semantics (delayed events — the category our purchase-on-delivery model lives in) |53| `references/conversions-api/capi-payload-helper.md` | Meta's interactive payload builder (for debugging shapes) |5455## How CodFlow maps onto these docs (quick orientation)5657- **Browser:** theme01's `BaseHead.astro` loads the canonical `fbevents.js`58 snippet (PageView on load); `thank-you.astro` fires the conversion event59 with `{ eventID: orderId }` — the fourth `fbq` argument, per the dedup doc.60- **Server:** `cod-server/src/workflows/capi.ts` (Cloudflare Workflow)61 sends the mirrored event via `/events` with `event_id: orderId`;62 `capi-helpers.ts` gates which status transitions trigger it;63 `capi_event_log` records what was sent (and powers idempotency).64- **Config:** `store_pixel_config` (pixel id, access token, test event65 code, conversion event choice, test mode) — Settings → Tracking.66- **Dedup contract:** browser `eventID` === CAPI `event_id` === orderId,67 same `event_name` on both sides. Any tracking change that breaks this68 equality double-counts conversions (see capi-deduplication.md).69- **Standard-event semantics:** which CodFlow moment maps to which Meta70 event is governed by pixel-reference-standard-events.md — notably71 `Purchase` is defined as at-checkout ("lands on thank you or72 confirmation page") and `Lead` as a completed sign-up. COD73 purchase-on-delivery is an offline-style delayed Purchase (see74 capi-offline-events.md) — legitimate, but it must be a deliberate75 merchant choice, not a silent default.7677## Working rules for tracking changes78791. **Ground first.** Read the relevant reference file(s) above before80 writing or reviewing a single line of tracking code. Cite the doc in81 the PR/review when a decision hinges on Meta behavior.822. **Never break the dedup equality** (browser eventID === server83 event_id, matching names) — silent double-counting or84 double-sending is the #1 tracking bug class.853. **A new conversion-event mode must fire from BOTH sides** (browser +86 CAPI mirror) or from exactly ONE side deliberately, never accidentally.87 PR #103's lesson: a mode that exists only in the settings enum is not a88 feature.894. **`capi_event_log` is the idempotency ledger** — anything that can fire90 twice (webhook retries, status toggles) must be guarded through it.915. **Test Mode** (`test_event_code`) exists for verification — use92 capi-verifying-setup.md's flow before claiming an event works.936. **Docs are read-only reference.** These files are unaltered Meta94 content (only a source header is prepended). Never edit them to match95 code — if code and docs disagree, the CODE changes (or Meta did, and96 we re-fetch).9798## Refreshing the docs99100Meta updates its docs; when a tracking question can't be answered from101these files (or the content looks outdated), re-fetch with Firecrawl:102103```sh104firecrawl scrape "https://developers.facebook.com/documentation/<path>" --only-main-content105```106107Keep the source header (URL + fetch date) on every file so staleness is108auditable. Content below the header stays unaltered.