Meta Pixel and Conversions API on a landing page
The Pixel alone misses a share of conversions to ad blockers, browser privacy settings and iOS limits. Sending the same events from your server too gives Meta a fuller picture to optimise your ads.
Updated · By Monish Kumar, founder of SprintWebs
How the two work together
- Meta Pixel: JavaScript in the visitor's browser that sends events such as PageView and Lead.
- Conversions API (CAPI): your server sends the same events directly to Meta.
When both send an event, Meta keeps one copy if they share the same event_name and event_id. This is called deduplication, and it's what lets you run both without double-counting.
Step 1: Install the Pixel
In Events Manager, open your dataset (Pixel) and copy the base code into the <head> of every page. It tracks PageView automatically.
Step 2: Fire a Lead event on submit
Only fire the Lead event after the form has been successfully submitted, and give it a unique ID:
const eventId = 'lead.' + crypto.randomUUID();
fbq('track', 'Lead', { content_name: 'Free demo class' }, { eventID: eventId });
// send eventId to your server together with the form data
Step 3: Send the same event from your server
Generate an access token in Events Manager → your dataset → Settings → Conversions API. Then, when your server receives the lead, post to the Graph API:
POST https://graph.facebook.com/v23.0/{PIXEL_ID}/events?access_token={TOKEN}
{
"data": [{
"event_name": "Lead",
"event_time": 1792850000,
"event_id": "lead.6f1c…",
"action_source": "website",
"event_source_url": "https://example.com/offer",
"user_data": {
"ph": ["<sha256 of 919876543210>"],
"em": ["<sha256 of lowercase email>"],
"client_ip_address": "203.0.113.7",
"client_user_agent": "Mozilla/5.0 …",
"fbp": "fb.1.1792840000.123456789",
"fbc": "fb.1.1792840000.IwAR…"
}
}]
}
Hash email and phone with SHA-256 after normalising them (lowercase email; phone with country code and digits only). Never send them unhashed. Keep the access token on the server only.
Step 4: Improve match quality
The more identifiers you send, the more conversions Meta can attribute:
_fbpcookie value asfbp_fbccookie, or build it from thefbclidURL parameter asfbc- Visitor IP address and user agent
- Hashed email, phone, name and city where you collect them
Step 5: Test before spending
In Events Manager, open Test events, copy the test code into your server requests, and submit your form. You should see the Lead event from both Browser and Server, marked as deduplicated. Remove the test code before launch.
Privacy
Mention the Pixel and Conversions API in your privacy policy, and honour consent requirements in the regions you advertise to.
Frequently asked questions
Do I need the Conversions API if I already have the Pixel?
It's strongly recommended for lead campaigns. Ad blockers and browser privacy features stop some Pixel events; the server copy fills the gap so Meta optimises on more of your real conversions.
Will running both double-count my leads?
Not if both send the same event name and event ID. Meta deduplicates them and keeps one.
What is a good Event Match Quality score?
Higher is better. Sending hashed email and phone plus fbp, fbc, IP address and user agent with each event usually lifts the score noticeably.