Skip to content

facebook-capi

Applies to: **/tracking/**, **/capi/**, **/pixel/**, **/meta/**, **/facebook/**

  • Every conversion event MUST have a matching event_id in both browser Pixel AND server CAPI
  • Generate event_id BEFORE the browser Pixel fires, pass the same value to the server
  • Deduplication window: 48 hours — Meta matches (event_name + event_id) pairs
  • If event_id is missing or mismatched, the same conversion counts twice

Target Event Match Quality (EMQ) score of ≥ 6.0. Tiers:

TierScoreParameters Required
Minimum viable≥ 4.0em, client_ip_address, client_user_agent
Good≥ 6.0+ ph, fbp, fbc
Excellent≥ 8.0+ fn, ln, external_id, ct, st, zp

All user data fields MUST be SHA-256 hashed before sending:

FieldNormalizationThen
Emaillowercase, trimSHA-256
PhoneE.164 digits only (no +, -, spaces)SHA-256
First namelowercase, trimSHA-256
Last namelowercase, trimSHA-256
Citylowercase, trim, remove spacesSHA-256
State2-letter code, lowercaseSHA-256
ZiptrimSHA-256

Never send raw PII. Different normalization = different hash = failed match.

For every CAPI event, forward from the HTTP request:

  • client_ip_address — from X-Forwarded-For or req.ip
  • client_user_agent — from User-Agent header
  • fbp — read _fbp cookie value
  • fbc — read _fbc cookie (set from fbclid URL parameter on landing)

Missing these fields degrades EMQ significantly.

  • event_time MUST be Unix timestamp in seconds (not milliseconds)
  • Math.floor(Date.now() / 1000) in JavaScript
  • int(time.time()) in Python
  • Use a supported Graph API version (v21.0–v24.0 as of 2026)
  • Versions expire after 2 years — check quarterly
  • Pin version in environment variable for easy updates
  • Use test_event_code during development (from Events Manager > Test Events)
  • REMOVE test_event_code before production deploy — test events don’t count toward attribution
  • Verify events appear in Events Manager within 20 seconds of sending
  • Maximum 1,000 events per CAPI request
  • Events older than 7 days are rejected
  • Rate limit: respect Meta’s 200 calls/hour guideline with exponential backoff