Table of contents
- Why tracking quality affects account health
- Pixel vs Conversions API: what each does
- Step 1: Verify your domain
- Step 2: Install the Pixel base code
- Step 3: Send the same events through CAPI
- Hash personal data correctly
- Step 4: Deduplicate browser and server events
- Step 5: Improve Event Match Quality
- Step 6: Configure Aggregated Event Measurement
- What not to send
- Using your pixel with a rented account
- Where to install the Pixel, platform by platform
- Plain HTML or a custom site
- WordPress
- Shopify and WooCommerce
- Next.js, React and other single-page apps
- Google Tag Manager
- Conversions API: a working server example
- How to confirm everything works
- Common problems and fixes
- Testing your setup before you spend
- Choosing a CAPI implementation
- Quick checklist
Most advertisers think of the Meta Pixel as a measurement tool. At scale, it's much more: it's the data feed that tells Meta's algorithm who your customers are, and it's part of the evidence Meta uses to judge whether your business is legitimate. A clean, complete Pixel and Conversions API (CAPI) setup improves results — and a sloppy one can put your account at risk.
This guide walks through a setup that works on your own accounts and on any account you get through facebook ads account rental.
Why tracking quality affects account health
Meta's systems look at the whole picture of an advertiser. A business that sends consistent, high-quality conversion events from a verified domain looks like what it is: a real company with real customers. An account that drives traffic to a domain with no events, broken events or suspicious data patterns looks riskier.
Tracking also affects cost. Better data means better optimization, which means lower CPA and fewer wasted impressions. In our client base, moving from Pixel-only to Pixel plus properly deduplicated CAPI lowers CPA by 10–25% on average.
Pixel vs Conversions API: what each does
| Meta Pixel | Conversions API | |
|---|---|---|
| Runs in | Visitor's browser | Your server |
| Affected by ad blockers | Yes | No |
| Affected by iOS/Safari limits | Yes | Much less |
| Can send offline events | No | Yes |
| Setup difficulty | Easy | Moderate |
You want both. The Pixel catches what it can in the browser; CAPI sends the same events from your server so nothing is lost.
Step 1: Verify your domain
In Business Settings, go to Brand Safety → Domains and add your domain. Verify with a DNS TXT record (recommended) or a meta-tag. Domain verification proves you control the site and is required for configuring web events.
If you're using a rented Business Manager, verify the domain in the BM that owns your pixel — ideally your own BM, so ownership stays with you.
Step 2: Install the Pixel base code
Add the base code to every page, inside the head. It initializes the pixel and fires a PageView event. On single-page apps (Next.js, React), also fire PageView on route changes.
Then add standard events where they happen:
- ViewContent on product pages
- AddToCart when an item is added
- InitiateCheckout at checkout start
- Purchase on the thank-you page, with value and currency
- Lead when a form is submitted
Use standard event names wherever possible. Custom events can't be used for optimization as easily.
Step 3: Send the same events through CAPI
Your server sends events to the Graph API endpoint for your pixel with an access token generated in Events Manager. Each event needs:
- event_name — matching the browser event (for example, Lead)
- event_time — Unix timestamp in seconds
- event_id — a unique ID, identical to the one sent by the browser
- action_source — "website"
- event_source_url — the page where the event happened
- user_data — hashed customer information plus IP and user agent
Hash personal data correctly
Email, phone, first name, last name, city and external ID must be normalized and hashed with SHA-256 before sending:
- Email: trim spaces, lowercase, then hash.
- Phone: digits only including country code, then hash.
- Names: lowercase, no punctuation, then hash.
Never send raw personal data. IP address, user agent and the fbp and fbc cookie values are sent unhashed.
Step 4: Deduplicate browser and server events
If both the Pixel and CAPI send a Lead event, Meta will count it twice unless you deduplicate. The rule is simple: send the same event_name and event_id from both. Generate the ID in the browser when the form is submitted, pass it to the Pixel as eventID, and send it to your server with the form data so CAPI uses the same value.
In Events Manager, the event details show a "Deduplicated" status when it works.
Step 5: Improve Event Match Quality
Event Match Quality (EMQ) scores how well Meta can match your events to real people. Raise it by sending more identifiers with each server event:
- Hashed email (biggest impact)
- Hashed phone number
- fbp and fbc cookies
- Client IP address and user agent
- Hashed external ID (your customer ID)
Most of our clients go from an EMQ of 4–6 to 8+ within a week of switching on full CAPI.
Step 6: Configure Aggregated Event Measurement
For iOS traffic, rank your conversion events by priority in Events Manager. Put your most valuable event (Purchase or Lead) at the top. Only the highest-priority event completed in a session is reported for opted-out iOS users.
What not to send
Some data can get your pixel or account restricted:
- Sensitive categories. Don't send health conditions, financial status or other sensitive information in URLs, event parameters or content names.
- Unhashed PII in any parameter, including in URL query strings.
- Events from pages you don't own.
Audit your URLs: a thank-you page like /thank-you?email=john@example.com leaks PII to the Pixel automatically.
Using your pixel with a rented account
When you rent a Facebook ads account, keep the pixel in your Business Manager and share it with the rented ad account. Your data, audiences and learning stay with you. If the ad account is ever replaced, you share the pixel to the new account and campaigns resume with full history. That's why pixel setup is included in our Growth and Scale plans.
Pair a solid tracking setup with a gradual spend ramp — see how to warm up a rented Facebook ads account — and new accounts exit learning much faster.
Where to install the Pixel, platform by platform
The Pixel base code is the same everywhere. What changes is where you paste it. Find your stack below.
Plain HTML or a custom site
Open the template shared by every page (usually a header or layout file) and paste the base code just before the closing head tag. Replace YOUR_PIXEL_ID with the ID from Events Manager → Data Sources → your pixel.
<script>
!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
document,'script','https://connect.facebook.net/en_US/fbevents.js');
fbq('init', 'YOUR_PIXEL_ID');
fbq('track', 'PageView');
</script>
WordPress
Use the official Meta for WordPress plugin (Facebook for WordPress) or a header-scripts plugin. Connect your Meta account in the plugin, choose the pixel, and switch on Conversions API. If you paste code by hand, add it to the header, not the footer, so PageView fires before the visitor leaves.
Shopify and WooCommerce
Install the Facebook & Instagram sales channel (Shopify) or Facebook for WooCommerce. Pick your pixel, set data sharing to Maximum, and confirm that email and phone are included. These integrations already send Purchase, AddToCart and ViewContent through both the browser and CAPI.
Next.js, React and other single-page apps
Load the base code once in the root layout, then fire PageView on every route change. Fire conversion events from the component that handles the action, for example the form submit handler.
// after the form is saved successfully
const eventId = crypto.randomUUID();
fbq('track', 'Lead', { content_name: 'contact-form' }, { eventID: eventId });
await fetch('/api/lead', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ ...formData, eventId }),
});
Google Tag Manager
Create a Custom HTML tag with the base code, trigger it on All Pages, and add one extra tag per event (Lead, Purchase) with the matching trigger. Use Preview mode to check each tag fires once, not twice. Do not install the same pixel through GTM and directly in the code, or every event is counted twice.
Conversions API: a working server example
Your server sends the same event the browser sent, using the same event_id. This Node.js sketch shows the whole request. The access token comes from Events Manager → Settings → Conversions API → Generate access token. Keep it in an environment variable and never in front-end code.
import crypto from 'node:crypto';
const sha256 = (v) =>
crypto.createHash('sha256').update(String(v).trim().toLowerCase()).digest('hex');
export async function sendLead({ email, phone, eventId, url, ip, userAgent, fbp, fbc }) {
const body = {
data: [{
event_name: 'Lead',
event_time: Math.floor(Date.now() / 1000),
event_id: eventId, // same value the browser sent
action_source: 'website',
event_source_url: url,
user_data: {
em: [sha256(email)],
ph: [sha256(phone.replace(/\D/g, ''))],
client_ip_address: ip, // not hashed
client_user_agent: userAgent, // not hashed
fbp, fbc, // not hashed
},
}],
// test_event_code: 'TEST12345', // only while testing
};
const res = await fetch(
`https://graph.facebook.com/v21.0/${process.env.PIXEL_ID}/events?access_token=${process.env.CAPI_TOKEN}`,
{ method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) }
);
return res.json();
}
Capture the fbclid from the landing URL and store it in a cookie. Building the fbc value from it lets Meta tie the lead back to the exact ad click, which is one of the strongest matching signals you can send.
How to confirm everything works
- In Events Manager → Test Events, open your site and submit the form. You should see the Lead event twice, labelled Browser and Server, merged into one line marked Deduplicated.
- Open Overview and check that Event Match Quality for Lead is 6.0 or more.
- Install the Meta Pixel Helper Chrome extension. A green icon with one PageView per page means the base code is firing once.
- Wait up to 24 hours. Then check Diagnostics for warnings such as missing parameters, duplicate events or a domain that is not verified.
Common problems and fixes
| Symptom | Likely cause | Fix |
|---|---|---|
| Every event is counted twice | Pixel installed in both GTM and code, or event_id missing | Keep one install; send identical event_id from browser and server |
| Server events show but Not Deduplicated | event_id differs or event_name differs | Generate the ID once, pass it to both |
| Match quality stuck below 5 | Only IP and user agent sent | Add hashed email, phone, fbp and fbc |
| Purchase has no value | Value and currency parameters missing | Send value as a number and currency as a 3-letter code |
| Pixel Helper shows nothing | Ad blocker, wrong page, or script after the closing body tag | Test in a clean browser profile; move code to the head |
| Events arrive but ads do not optimize | Wrong event chosen as the campaign goal | Pick the event that matches your goal, for example Lead for Leads campaigns |
Testing your setup before you spend
Before driving real traffic, test the whole chain:
- Open Events Manager → Test Events and enter your site URL. Browse your site and complete a test conversion.
- Confirm the browser event arrives with the right parameters (value, currency, content IDs).
- Send a server test event using the test event code in your CAPI requests. It should appear in the same Test Events view.
- Check deduplication. Complete one test conversion; you should see a single deduplicated event, not two.
- Review the event details for Event Match Quality and the identifiers received.
- Remove the test event code before going live, so production events aren't flagged as tests.
Choosing a CAPI implementation
There are three common ways to implement Conversions API:
| Method | Effort | Flexibility |
|---|---|---|
| Platform integration (Shopify, WooCommerce) | Low | Limited |
| Conversions API Gateway | Medium | Good |
| Custom server integration | Higher | Full control |
Ecommerce stores on major platforms should start with the built-in integration and check that it sends email and phone. Lead-gen sites and custom stacks usually benefit from a direct server integration, where the form handler sends the Lead event right after saving the lead.
Quick checklist
- Domain verified in the BM that owns the pixel
- Pixel base code on every page, PageView on route change
- Standard events on key actions
- CAPI sending the same events with matching event_id
- Email and phone hashed with SHA-256
- EMQ of 6+ on your main conversion event
- No sensitive data in URLs or parameters
For more on keeping accounts healthy, read why your Facebook ads account keeps getting banned.
Want it done for you? HD Agency installs the Pixel, verifies your domain and sets up deduplicated Conversions API for every client, and we can share the finished pixel to your ad account. Message us on Telegram or WhatsApp and we reply in about 5 minutes. See the plans or the industry setups.
Frequently asked questions
Do I still need the Pixel if I use Conversions API?
Yes. Meta recommends running both. The Pixel captures browser events and cookies, while CAPI fills the gaps caused by ad blockers and browser privacy features. Deduplication prevents double counting.
What is a good Event Match Quality score?
Aim for 6.0 or higher for Purchase and Lead events. Scores above 8 are excellent and usually come from sending hashed email, phone and external ID with every server event.
Can a bad pixel setup get my account banned?
Tracking alone rarely causes a ban, but sending unhashed personal data or sensitive health or financial information can violate Meta's business tools terms and lead to restrictions.
Can I use the same pixel on a rented agency account?
Yes. You keep ownership of your pixel in your own Business Manager and share it with the rented ad account, so all your historical data stays with you.
Written by
HD Agency
The HD Agency media buying team. 5+ years scaling ecommerce, lead-gen and app offers on Meta across the US and EU, with millions in managed ad spend. We write about ad account infrastructure, tracking and scaling without interruptions.
Message HD Agency