The Facebook Conversions API (CAPI) is no longer a nice-to-have. Every meaningful signal loss event of the last several years - iOS 14.5 App Tracking Transparency, Safari Intelligent Tracking Prevention, iOS 17 Link Tracking Protection stripping fbclid from inbound URLs - has chipped away at the Meta Pixel’s ability to report conversions accurately. If your facebook capi setup is still on the backlog, this guide walks you through the entire facebook capi implementation from first principles: prerequisites, generating your access token, choosing the right integration method, hashing user_data correctly, hitting the right Event Match Quality score, verifying with Test Events, and handling the errors everyone eventually hits.
This is a setup and implementation guide. Deduplication - preventing double-counting when you run the Pixel and CAPI simultaneously - is a separate concern covered in depth in Facebook CAPI Deduplication: Why Your Conversions Doubled. Read both.
Why CAPI Is Essential in 2026: iOS ATT, Safari ITP, and Ad Blockers
Three independent forces have been degrading the Meta Pixel in parallel.
iOS App Tracking Transparency (ATT), launched with iOS 14.5 in April 2021 and permanent since, requires explicit opt-in before Meta can set tracking cookies or read the IDFA on Apple devices. Users who opt out cannot be tracked by the Pixel at all. See the iOS ATT glossary entry for the technical scope.
Safari Intelligent Tracking Prevention (ITP) caps the lifetime of first-party cookies set via JavaScript (document.cookie) to 7 days - and to 24 hours when the visitor arrives on a link-decorated URL from a domain Safari classifies as a tracker. The _fbp Pixel cookie is written by JavaScript and normally persists roughly 90 days, so on Safari it is functionally destroyed: it survives at most a week. Cookies set server-side via an HTTP Set-Cookie header are not subject to this cap - the basis of the server-side workaround described later in this guide. Attribution windows that depend on a persistent _fbp fall apart.
iOS 17 Link Tracking Protection strips fbclid from inbound URLs by default, which prevents the _fbc click ID cookie from being created at all on those sessions. There is no reliable client-side workaround.
Ad blockers block the Meta Pixel JavaScript file before it executes. CAPI is immune to this entirely because it runs server-to-server - your server sends the event directly to Meta’s Graph API, bypassing the browser.
None of these forces are going away. Chrome third-party cookies remain a separate topic: Google announced in July 2024 that forced deprecation would not proceed, and confirmed in April 2025 that no separate consent prompt would be added. Third-party cookies remain enabled by default in Chrome. The browser signal loss problem is real and severe regardless - it comes from Apple, not Google.
Meta’s own guidance is to run the Conversions API alongside the Pixel rather than instead of it, because the combination improves the completeness of the conversion signal and, in turn, delivery efficiency. The mechanism is straightforward: better event coverage means the delivery algorithm optimizes against a more complete signal.
CAPI and the Meta Pixel: Complementary by Design
CAPI is not a replacement for the Meta Pixel - run both simultaneously. The Pixel contributes _fbp and _fbc cookies that improve Event Match Quality and fires ViewContent and AddToCart events reliably. CAPI catches what the Pixel misses: blocked sessions, Safari-truncated sessions, and delayed checkout completions. For signal loss context, see Why Server-Side Tracking Matters.
Prerequisites: What You Need Before Starting Your Facebook CAPI Integration
Before writing a single line of code or clicking through Events Manager, confirm you have:
- A Meta Business Manager account at business.facebook.com - not a personal ad account.
- An existing Meta Pixel / Dataset already installed on your site. The Pixel is the source of
_fbpcookies and the reference point for deduplication. It is technically possible to run CAPI without a Pixel, but you lose match quality and deduplication reliability. - Developer role in Business Manager. The access token generation UI is only visible to users with the Developer role - Admin alone is insufficient. Go to Business Settings and confirm your role before spending time in Events Manager.
- An HTTPS-enabled website with your domain verified in Meta Business Suite. Domain verification is required for Attribution.
- A server capable of making outbound HTTPS POST requests - any backend language or runtime works.
Step 1 - Find Your Dataset ID (It Is Your Pixel ID)
Meta unified its separate event-source concepts (Pixel, offline event set, app event set) into a single “Dataset” concept several years ago. The Dataset ID is numerically identical to your original Pixel ID - no new identifier was issued. Older accounts may still show “Pixel ID” in some UI panels; both labels refer to the same number and are fully interoperable.
To find it: Events Manager - Data Sources (left sidebar) - select your Pixel/Dataset - Settings tab - look for “Dataset ID” or “Pixel ID”. Copy the numeric value. This is the identifier you will embed in every API endpoint URL.
Step 2 - Generate Your Conversions API Access Token
You have two paths. Use Method B for any production deployment.
Method A - Events Manager (quickest for testing):
- Events Manager - select your Dataset/Pixel
- Settings tab - scroll to the Conversions API section - “Set up manually” - click “Generate access token”
- Copy the token immediately. Meta does not store it and will not display it again.
Tokens generated this way are tied to your personal user account. They expire or become invalid if your Facebook password changes, your account is locked, or the token is regenerated. This is acceptable for local testing; it is not suitable for production.
Method B - Business Manager System User (recommended for production):
- Business Settings - System Users - create or select a System User
- Assign the relevant Pixel/Dataset to the System User
- Generate Token - grant at minimum the
events_managementpermission - Tokens from this path are long-lived and do not expire unless you explicitly revoke them
Use Method B. Personal user tokens in production are a maintenance liability - the first time a developer changes their Facebook password, your CAPI integration silently stops sending events.
Choosing the Right CAPI Implementation Method: Four Approaches Compared
There is no single correct implementation method. Choose based on your technical capability, how much server-side data you want to enrich events with, and your existing infrastructure.
Method 1: Manual Server-Side Code - PHP Business SDK and Raw HTTP
Manual server-side code gives you the highest possible data accuracy and control. You have access to every order field - customer email, phone, address, external CRM ID - at the time the event fires, and you can pass all of it.
Using the PHP Business SDK:
use FacebookAds\Object\ServerSide\EventRequest;
use FacebookAds\Object\ServerSide\Event;
use FacebookAds\Object\ServerSide\UserData;
use FacebookAds\Object\ServerSide\CustomData;
use FacebookAds\Object\ServerSide\ActionSource;
$userData = (new UserData())
->setEmail('customer@example.com') // SDK normalizes; check SDK docs before pre-hashing
->setPhone('15551234567')
->setClientIpAddress($_SERVER['REMOTE_ADDR'])
->setClientUserAgent($_SERVER['HTTP_USER_AGENT'])
->setFbp($_COOKIE['_fbp'] ?? null)
->setFbc($_COOKIE['_fbc'] ?? null);
$customData = (new CustomData())
->setCurrency('USD')
->setValue(99.99);
$event = (new Event())
->setEventName('Purchase')
->setEventTime(time())
->setEventId('ORDER-' . $orderId)
->setActionSource(ActionSource::WEBSITE)
->setEventSourceUrl('https://example.com/order/confirm')
->setUserData($userData)
->setCustomData($customData);
$request = (new EventRequest($accessToken))
->setPixelId($datasetId)
->setEvents([$event]);
$request->execute();
Note on hashing: the PHP Business SDK’s UserData setters accept plain text strings and apply normalization internally. If you are using the SDK, do not manually SHA-256 hash PII before passing it in - you risk double-hashing. Check the SDK documentation for your installed version. If you are sending raw HTTP without any SDK, you must manually SHA-256 hash all PII fields following the normalization rules in the section below.
Raw HTTP (no SDK):
POST https://graph.facebook.com/v26.0/{DATASET_ID}/events?access_token={TOKEN}
{
"data": [{
"event_name": "Purchase",
"event_time": 1727052000,
"event_id": "ORDER-12345",
"action_source": "website",
"event_source_url": "https://example.com/order-confirm",
"user_data": {
"em": ["<sha256_of_lowercased_trimmed_email>"],
"ph": ["<sha256_of_e164_phone>"],
"client_ip_address": "203.0.113.1",
"client_user_agent": "Mozilla/5.0 ...",
"fbp": "fb.1.1717099212345.987654321",
"fbc": "fb.1.1717099212345.AQzXy1abc..."
},
"custom_data": {
"currency": "USD",
"value": 99.99,
"order_id": "ORD-123"
}
}]
}
Add "test_event_code": "TEST12345" (the code shown in your Test Events tab) during development. Remove it before production deployment.
Graph API version: Always verify the current stable version at developers.facebook.com/docs/graph-api/changelog/versions before pinning. v22.0 was confirmed current as of late 2025; v23.0 may have been released by June 2026. Pinning a deprecated version (v19.0 was deprecated February 4, 2025; v20.0 on May 6, 2025) will eventually stop working without warning.
Method 2: Meta Conversions API Gateway (CAPIG) - No-Code, Meta-Hosted
CAPIG is open-source middleware maintained by Meta. You deploy it to your own cloud (AWS EKS, AWS ECS Express, or GCP). Setup is UI-driven from Events Manager - Settings - Conversions API - Set Up CAPI Gateway. No coding required.
The trade-off: CAPIG handles web events only. It cannot send app events, offline conversions, or backend-triggered events (such as a refund or subscription renewal fired from your CRM). It also cannot enrich events with server-side data beyond what the Pixel captured in the browser session. Meta’s CAPIG software is free; the cloud infrastructure you run it on carries its own cost.
For teams without backend engineering resources who primarily need browser event coverage, CAPIG is the correct starting point.
Method 3: Server-Side Google Tag Manager (sGTM)
A GTM server container deployed to Google Cloud Run (the standard path) or another Docker host acts as a first-party proxy between your browser and all destination ad platforms. You configure one container, deploy a single Meta CAPI tag, and can route the same events to Google Ads, TikTok Events API, and LinkedIn simultaneously - without maintaining separate server-side integrations for each.
A concrete advantage beyond Meta: sGTM lets you set HttpOnly first-party cookies from a server response, which bypasses Safari ITP’s 7-day cap on cookies set by JavaScript. Your _fbp equivalent survives ITP. Cloud Run costs run approximately $50-200/month for typical e-commerce traffic.
If your team already has GTM expertise and wants a vendor-neutral server layer, sGTM is the most flexible option.
Method 4: Platform Plugins and the Meta-Enabled One-Click CAPI (April 2026)
For standard e-commerce platforms, the fastest path to a working capi integration is a native plugin that handles both the Pixel and the CAPI call from a single configuration screen.
Shopify has a native Meta integration (Shopify admin - Settings - Apps and sales channels - Facebook and Instagram) that covers Pixel plus CAPI. Note that Shopify - not Meta - retired checkout.liquid and froze the Additional Scripts field for Plus stores in August 2025; if you rely on legacy checkout snippets, see our dedicated Shopify server-side tracking guide and verify your data pass-through with the Test Events tool.
Meta-enabled one-click CAPI (April 2026): Meta launched a no-code, Meta-hosted option directly in Events Manager in April 2026. Setup: Events Manager - Connect Data - Web - “See other ways to setup” - “Set up with Meta”. Web events only; no server enrichment.
user_data Fields: What to Send, What to Hash, and How to Normalize It
The user_data object is the primary driver of Event Match Quality. More correctly-hashed parameters means Meta can match the server event to a user in its system with higher confidence.
Fields you must SHA-256 hash (normalize first):
| Field | Key | Normalization before hashing |
|---|---|---|
em |
Lowercase, trim whitespace | |
| Phone | ph |
E.164 format - digits and country code only, e.g. 15551234567 |
| First name | fn |
Lowercase |
| Last name | ln |
Lowercase |
| Gender | ge |
Single character: m or f |
| Date of birth | db |
YYYYMMDD |
| City | ct |
Lowercase, no spaces or punctuation |
| State | st |
2-letter ISO code, lowercase |
| Zip/postal | zp |
Lowercase, no spaces or dashes |
| Country | country |
ISO 3166-1 alpha-2, lowercase |
Fields you must NOT hash - send as plain text:
| Field | Key |
|---|---|
| Facebook Pixel cookie | fbp |
| Facebook Click ID | fbc |
| Client IP address | client_ip_address |
| Client user agent | client_user_agent |
Hashing fbp, fbc, client_ip_address, or client_user_agent will cause those parameters to fail their match entirely. They are structural identifiers, not PII.
external_id (a stable CRM or customer ID from your system): SHA-256 hashing is recommended best practice. Sources differ on whether it is strictly required; treat it as a strong recommendation, not a hard rule.
For the full Conversions API parameter reference, see our glossary entry.
The fbp and fbc Cookies: Capturing and Passing Click Identity Server-Side
These two cookies are your highest-value non-PII match parameters and must be sent as plain text - never hashed.
_fbp (format: fb.1.[timestamp_ms].[random]) is set by the Meta Pixel on first visit and persists approximately 90 days on non-Safari browsers. Read it server-side: $_COOKIE['_fbp'] in PHP, req.cookies['_fbp'] in Node.js.
_fbc (format: fb.1.[timestamp_ms].[fbclid]) is set when the landing URL contains ?fbclid=. If the cookie is absent but fbclid is in the request URL, construct it server-side: fb.1. + current milliseconds + . + the fbclid value. Setting it as a server-side HttpOnly cookie on landing bypasses Safari ITP’s 7-day cap.
iOS 17 Link Tracking Protection strips fbclid from URLs by default - sessions from iOS 17+ Safari will often have neither cookie nor a recoverable fbclid. This is the environment, not a bug.
action_source, event_time, and event_id: The Three Parameters Everyone Gets Wrong
These three are responsible for the majority of 400 errors and silent data quality issues.
action_source has been required on every CAPI event since February 15, 2021. Events missing it may be discarded. Valid values: website, app, email, phone_call, chat, physical_store, system_generated, other. When action_source is website, client_user_agent and event_source_url are also required.
event_time must be a Unix timestamp in seconds - a 10-digit integer. JavaScript’s Date.now() returns milliseconds (13 digits). Use Math.floor(Date.now() / 1000). PHP: use time() directly. Submitting millisecond timestamps produces values that land in the year 2527, which gets events rejected or silently discarded.
event_id is the deduplication key. Generate a UUIDv4 (or use a scoped order ID like ORDER-12345) and pass the exact same string to fbq('track', 'Purchase', {...}, {eventID: 'ORDER-12345'}) in the browser and to event_id in the CAPI payload. Different values on each side means Meta counts the conversion twice. The full mechanics are in Facebook CAPI Deduplication.
Event Match Quality (EMQ): Scores, Targets, and How to Push Yours Above 8
Event Match Quality is a score from 0-10 visible in Events Manager that reflects how reliably Meta can match your server events to users in its system. It updates every 48 hours.
Score bands:
- 8-10: Great - Meta reliably identifies the user
- 6-7: Good - acceptable minimum; room to improve
- 3-5: OK - weak identifiers; optimization is impaired
- 0-2: Poor - events are heavily underweighted by Meta’s delivery algorithm
Target 6 as your floor, 8 as your goal. Below 6, CAPI events are contributing limited signal to delivery optimization. The Event Match Quality glossary entry covers the concept in detail.
What moves the score upward (priority order, high to low): email em, phone ph, fbp and fbc (sent as plaintext), first and last name (fn/ln), location fields (ct/st/zp/country), client_ip_address and client_user_agent, external_id. Note these priority rankings are community-derived; Meta does not publish an official per-parameter scoring formula.
The Diagnostics tab in Events Manager surfaces per-event warnings such as “0% of events include email.” Fix the highest-coverage warnings first - email is the single highest-impact parameter.
Verifying Your Facebook CAPI Integration with Test Events
Before sending events to production, verify using the Test Events tab in Events Manager:
- Events Manager - Data Sources - select your Dataset - “Test Events” tab
- Copy the test event code shown (format:
TEST12345) - Add
"test_event_code": "TEST12345"as a top-level field in your CAPI payload - without it, server events do not appear in Test Events at all; they flow silently to production - Trigger the event and confirm it appears labeled “Server/CAPI” with action_source “website”, expected user_data parameters populated, and event_id present
- If you are firing both Pixel and CAPI simultaneously, verify the pair is reported as deduplicated
Remove test_event_code before going to production. Test events still flow into audience building and measurement even in the test window. Leaving the code in production pollutes live data.
Deduplication: Preventing Double-Counting When Running Pixel and CAPI Together
Run both the Pixel and CAPI. On every conversion event, generate one UUID, pass eventID: 'uuid' in the browser fbq() call and event_id: 'uuid' in the CAPI payload. The event_name must match exactly (PascalCase: Purchase, AddToCart). Meta deduplicates on matching event_name plus event_id within a deduplication window; this figure is consistently cited across implementation guides as 48 hours, though this could not be verified directly against the primary Meta documentation page.
The full failure taxonomy - camelCase vs. snake_case trap, millisecond timestamps, ID format mismatches, multiple Pixel IDs on one domain - is in the deduplication guide. Read it before shipping.
Troubleshooting Common CAPI Errors
HTTP 401 - Invalid or Expired Token: Personal user tokens expire when a Facebook password changes or an account is locked. Switch to a Business Manager System User token. Verify the System User has “Manage Pixel” permission on the correct Dataset.
HTTP 400 - Wrong Hashing: Either SHA-256 applied without pre-normalization (email not lowercased, phone not reduced to E.164 digits-only), or SHA-256 applied to fields that must not be hashed (fbp, fbc, client_ip_address, client_user_agent).
HTTP 400 - event_time in Milliseconds: Date.now() returns 13 digits. CAPI requires 10-digit seconds. Use Math.floor(Date.now() / 1000). This is the most common rejected-event cause in JavaScript implementations.
HTTP 400 - Missing action_source: Required on every event since February 15, 2021. When action_source is website, also include client_user_agent and event_source_url.
Duplicate Counting: Both Pixel and CAPI fire for the same conversion without a shared event_id, or the IDs differ by a formatting issue (one includes a # prefix). See the deduplication guide for the complete diagnostic workflow.
On HTTP 500, retry with exponential backoff; use a 1,500ms request timeout. The 400 response body always contains field-level detail - read it before debugging blindly.
Privacy and Compliance: CCPA Limited Data Use and GDPR Consent Handling
CCPA / Limited Data Use (LDU): For California users who have opted out, include "data_processing_options": ["LDU"], "data_processing_options_country": 1, "data_processing_options_state": 1000. Meta counts the conversion for reporting but does not use it for targeting or lookalike modeling. For sessions with no restriction: "data_processing_options": [].
GDPR: Gate all CAPI calls behind your consent management platform. Do not send events for non-consenting users - the server-side delivery path does not exempt you from consent obligations.
Meta AEM update: Meta has moved away from the original eight-conversion-event-per-domain cap that iOS ATT introduced, automatically aggregating eligible events rather than requiring manual prioritization. Domain verification remains required for iOS app setups. Confirm the current Aggregated Event Measurement rules against Meta’s documentation before relying on a specific event count.
How AxiTrace Handles the Entire CAPI Integration for You
Every step in this guide - generating event IDs, hashing PII, reading fbp/fbc cookies, setting action_source correctly, retrying on failure - is work your team must maintain indefinitely. A single misconfigured field silently degrades attribution.
AxiTrace is a server-side conversion tracking platform. A single browser SDK forwards events to the AxiTrace ingestion API, which then sends them server-side to Meta CAPI, TikTok Events API, Google Ads, and GA4 simultaneously. Meta is one of the 9 destinations of the AxiTrace Conversion API, alongside Google Ads, TikTok, GA4, Pinterest, Reddit, LinkedIn, Microsoft Ads and OpenAI Ads.
- One event_id minted at ingestion - used for both the browser Pixel call and the CAPI call, stable across retries. The deduplication failure modes in the deduplication guide cannot occur. See Facebook CAPI.
- PII SHA-256 hashed server-side with normalization applied - no double-hashing, no missed fields.
- fbp and fbc captured and forwarded as plaintext on every event.
- Native plugins for Shopify, WooCommerce, Magento 2, and Shopware 6 - one canonical event source, no fragmented multi-Pixel setups.
- The same pipeline also forwards to TikTok Events API and Google Ads enhanced conversions with the correct field names for each platform.
Getting Started
- Install the plugin for your platform: Shopify App Store, WordPress.org for WooCommerce, or Packagist for Magento 2 and Shopware 6.
- Connect your Meta Pixel/Dataset ID and your CAPI access token (System User recommended) in the AxiTrace dashboard.
- AxiTrace handles event_id generation, PII hashing, fbp/fbc forwarding, and payload construction. There are no CAPI parameters to misconfigure.
- Open Events Manager - Test Events tab and fire a test purchase to confirm events arrive with correct parameters and deduplication status within minutes.
The free tier covers 10,000 visits per month - sufficient to run the full verification workflow before committing to a paid plan.
Frequently Asked Questions
What is the difference between a Dataset ID and a Pixel ID?
They are the same number. Meta unified its Pixel, offline event set, and app event set concepts into a single “Dataset” entity. If your account was created before the transition, it may still display “Pixel ID” in some panels; the numeric value is identical to the Dataset ID and interchangeable in API calls. The API endpoint uses whichever number you have.
What Graph API version should I use for my CAPI integration?
Always check developers.facebook.com/docs/graph-api/changelog/versions before pinning a version. v22.0 was the confirmed current version as of late 2025; v23.0 may have been released by June 2026. Avoid pinning a deprecated version - v19.0 was deprecated February 4, 2025 and v20.0 on May 6, 2025. Deprecated versions stop working without advance notice once the deprecation period ends.
Does my CAPI access token expire?
Tokens generated via Events Manager from your personal Facebook account expire when your password changes or the token is regenerated. Tokens generated for a Business Manager System User do not expire unless you explicitly revoke them. Use System User tokens in production.
What is the minimum user_data I need to send?
At minimum, one customer information parameter must be present. In practice, you need at least client_ip_address and client_user_agent to get any meaningful Event Match Quality score. Email (em) is the highest-impact single parameter - if you can only pass one PII field, pass hashed email. Combine it with fbp (plain text, from the _fbp cookie) for a meaningful baseline.
My EMQ score is stuck below 6. What should I check?
First, check the Diagnostics tab in Events Manager for per-event warnings - it will tell you which parameters have 0% coverage. Then verify in order: (1) are you passing em (hashed email) and ph (hashed phone in E.164 format) on every conversion event? (2) is fbp being read from the cookie and sent as plain text? (3) are location fields (ct, st, zp, country) populated from your order data? Each additional correctly-normalized parameter improves the score.
Can I send CAPI events without running the Meta Pixel at all?
Yes. CAPI works standalone. However, you lose _fbp cookie values (which require the Pixel to set), which reduces Event Match Quality. You also lose Pixel-generated ViewContent and AddToCart events unless you fire those server-side too. For most setups, running the Pixel alongside CAPI deduplicated properly is strictly better than either alone.
What happened to the Offline Conversions API?
The old Offline Conversions API (OCAPI) was deprecated and disabled as of May 2025. Offline events - walk-in store purchases, phone orders, field sales - now flow through the same CAPI endpoint using action_source values of physical_store or other against a unified Dataset. If you are still using the legacy OCAPI endpoint, migration is overdue.
Get tracking insights in your inbox
Tips on server-side tracking, conversion optimization, and product updates. Delivered weekly.
No spam. Unsubscribe anytime.