Conversion Tracking
20 minute read

How to Set Up Facebook Conversion API: A Complete Step-by-Step Guide for Marketers

Written by

Grant Cooper

Founder at Cometly

Follow On YouTube

Published on
April 29, 2026

Facebook Pixel alone no longer captures the full picture of your ad performance. With browser restrictions, iOS privacy updates, and ad blockers becoming the norm, marketers are losing visibility into conversions that actually happen. The data gap is real: browser-based tracking misses a growing percentage of conversions, leaving your ad optimization algorithms working with incomplete information.

Facebook Conversion API (CAPI) solves this by sending event data directly from your server to Meta, bypassing browser limitations entirely. Instead of relying on cookies and browser pixels that users can block or that iOS privacy features can restrict, CAPI establishes a direct server-to-server connection that captures conversion events reliably.

This guide walks you through the complete setup process, from creating your access token to verifying your events are firing correctly. By the end, you will have a working Conversion API implementation that improves your tracking accuracy and feeds better data back to Meta's optimization algorithms.

Whether you are setting this up manually or using a partner integration, these steps will get you tracking conversions reliably. The technical setup requires attention to detail, but each step builds logically on the previous one. Let's get started.

Step 1: Access Your Facebook Events Manager and Create Your Pixel

Your first step is navigating to Events Manager within your Meta Business Suite. This is where all your tracking infrastructure lives, and where you will manage both your Pixel and Conversion API setup.

Log into your Meta Business Manager account and locate Events Manager in the left navigation menu. If you are managing multiple businesses, make sure you have selected the correct Business Manager account before proceeding. This matters because your Pixel and access tokens are tied to specific business accounts.

Once inside Events Manager, you will see a list of your existing data sources. If you already have a Facebook Pixel installed on your website, locate it in this list. If you are starting fresh, click the green "Connect Data Sources" button and select "Web" to create a new pixel.

When creating a new pixel, Meta will ask you to name it. Use a descriptive name that identifies which website or property it tracks, especially if you manage multiple sites. Something like "Company Website - Main Pixel" works better than generic names when you are troubleshooting later.

Why this matters: Your Pixel ID is the foundation that connects CAPI events to your ad account. Every server-side event you send will reference this Pixel ID, so documenting it accurately is critical. Understanding the conversion API vs Facebook Pixel differences helps you leverage both effectively.

After creating or locating your pixel, click on it to view the details page. In the top section, you will see your Pixel ID displayed as a long numerical string. Copy this ID and store it somewhere secure, like a password manager or your project documentation. You will need this exact ID when configuring your server-side implementation.

Before moving forward, verify that you have admin access to both the Business Manager and the specific ad account you are working with. CAPI setup requires elevated permissions because you are creating access tokens that authorize server-to-server data transmission. If you only have analyst or advertiser access, you will need to request admin permissions from your Business Manager administrator.

Take a moment to confirm the correct ad account is selected in the top-right dropdown menu. Setting up CAPI under the wrong ad account means your conversion data will flow to the wrong place, and untangling that later creates unnecessary headaches.

Step 2: Generate Your Conversion API Access Token

With your Pixel ID documented, the next critical piece is generating an access token that authorizes your server to send events to Meta. This token functions like a secure password that authenticates your server-side requests.

In Events Manager, make sure your pixel is selected, then navigate to the Settings tab. Scroll down until you find the "Conversions API" section. This is where Meta centralizes all CAPI-related configuration.

Click the "Generate Access Token" button. Meta will display a modal explaining what this token does and the permissions it grants. Read this carefully because once you close this modal, you cannot view the full token again. If you lose it, you will need to generate a new one and update your server configuration.

When you click "Generate," Meta creates a long alphanumeric string that looks something like a random sequence of letters and numbers. This is your access token. Immediately copy it and store it in a secure location. Never share this token publicly or commit it to version control systems like GitHub.

Best practice: Store tokens in environment variables, never hardcode them in your application. If someone gains access to this token, they can send event data to your Meta account, potentially corrupting your analytics or exhausting your API limits. For a complete walkthrough, check out our Facebook Conversion API guide.

Understanding token permissions helps you manage security properly. This access token specifically authorizes server-to-server communication with Meta's Marketing API. It allows your server to send conversion events, but it does not grant access to modify your ad campaigns, view financial information, or change Business Manager settings.

The token does not expire automatically, but you can revoke it at any time from the same Settings page in Events Manager. If you suspect your token has been compromised, revoke it immediately and generate a new one. You will then need to update your server configuration with the new token.

Some teams manage multiple environments like development, staging, and production. In these cases, consider generating separate access tokens for each environment. This isolation prevents test events from polluting your production analytics and makes it easier to troubleshoot issues.

Document where you stored this token and who has access to it. In larger organizations, access token management becomes a security concern. Only developers and systems that actually need to send events should have access to this credential.

Once your token is securely stored, you are ready to configure the events your server will send. The token itself does not do anything until your server starts making API calls with it, which we will set up in the following steps.

Step 3: Configure Your Server-Side Event Parameters

Now comes the planning phase: deciding which events to track and what data to include with each one. This step happens before you write any code, and getting it right determines how valuable your CAPI implementation becomes.

Start by defining which conversion events matter for your business. Meta supports standard events like Purchase, Lead, AddToCart, InitiateCheckout, CompleteRegistration, and ViewContent. You can also create custom events for business-specific actions. Most e-commerce businesses prioritize Purchase and AddToCart, while lead generation businesses focus on Lead and CompleteRegistration.

Each event you send must include several required parameters. The event_name identifies what happened, like "Purchase" or "Lead." The event_time records when the conversion occurred as a Unix timestamp (seconds since January 1, 1970). The action_source tells Meta where the event originated, and for website conversions, this must always be "website."

The user_data object is where CAPI becomes powerful. This object contains customer information that helps Meta match your server-side events to actual Facebook users. The more parameters you include here, the better Meta can attribute conversions and optimize your campaigns. Learn more about conversion API for better tracking to maximize your implementation.

Critical requirement: All personally identifiable information in user_data must be hashed using SHA-256 before sending. This includes email addresses, phone numbers, first names, last names, and any other customer data. Meta requires lowercase values with no spaces before hashing.

The most valuable user_data parameters are email (em), phone (ph), and external_id. Email and phone should be hashed versions of the customer's contact information. The external_id is typically your internal customer ID or user ID, also hashed. Including all three significantly improves your Event Match Quality score.

Beyond these core identifiers, you can include additional parameters like client_ip_address, client_user_agent, fbp (the Facebook browser pixel cookie value), and fbc (the Facebook click ID). These parameters improve matching accuracy without requiring personal information.

For e-commerce events, include custom_data parameters like value (purchase amount), currency, and content_ids (product SKUs). This data enables Meta to optimize for return on ad spend (ROAS) rather than just conversion volume.

One parameter deserves special attention: event_id. This unique identifier enables deduplication when you run both Pixel and CAPI simultaneously. Generate a unique ID for each conversion (a UUID works well), and pass this same ID to both your browser pixel and your server-side CAPI event. Meta uses this to recognize when both sources report the same conversion and counts it only once.

Document your event schema before implementation. Create a spreadsheet or technical document listing each event you will track, all required and optional parameters for that event, and where your application will source each piece of data. This planning prevents gaps in your implementation and makes troubleshooting easier later.

Consider data quality at this stage. If your application does not reliably capture email addresses at the point of conversion, you cannot include them in your CAPI events. Identify any data gaps now and work with your development team to capture the necessary information before the conversion occurs.

Step 4: Implement the API Connection on Your Server

With your events planned and parameters defined, it is time to implement the actual server-side code that sends events to Meta. You have several implementation options depending on your technical setup and resources.

The direct implementation approach involves your server making POST requests to Meta's Marketing API endpoint. The endpoint URL follows this format: graph.facebook.com/v18.0/{pixel_id}/events, where you replace {pixel_id} with your actual Pixel ID from Step 1.

Each API request must include your access token in the request header for authentication. The token goes in the Authorization header as a Bearer token, or you can include it as an access_token parameter in the request URL. Most developers prefer the header approach for better security.

Your request payload must be formatted as JSON and include a data array containing one or more event objects. Each event object contains the parameters you defined in Step 3: event_name, event_time, action_source, user_data, and any custom_data relevant to that event.

Here is what the structure looks like conceptually: You create a JSON object with a data array. Inside that array, each conversion becomes an event object with all its required fields. The user_data field is itself an object containing the hashed customer information. You send this entire structure as the body of your POST request.

Many developers choose partner integrations instead of direct implementation. Meta maintains partnerships with platforms like Segment, Google Tag Manager Server-Side, and various e-commerce platforms. These partners provide pre-built integrations that handle the API communication for you. If your website runs on Shopify, WordPress, or another major platform, check whether a CAPI plugin exists before building from scratch. Understanding conversion API setup challenges helps you anticipate common roadblocks.

For custom implementations, choose a programming language your team knows well. Meta provides official SDKs for Python, PHP, Node.js, and Java that simplify the API interaction. These SDKs handle request formatting, error handling, and retry logic automatically.

Implement error handling in your server code. Network issues, API rate limits, and invalid parameters can cause requests to fail. Your code should log these failures for debugging and potentially queue failed events for retry. Meta's API returns detailed error messages that identify exactly what went wrong.

Consider the timing of your API calls. Some implementations send events synchronously immediately after the conversion occurs. Others queue events and send them in batches. Batching reduces server load and API calls, but synchronous sending provides faster data for Meta's optimization algorithms. For most businesses, sending events within a few seconds of the conversion strikes the right balance.

Test your implementation in a development environment first. Send test events (which we will cover in Step 6) before pointing your production traffic at the API. This prevents bad data from corrupting your live analytics while you work out implementation bugs.

Step 5: Set Up Event Deduplication to Avoid Double Counting

Running both Facebook Pixel and Conversion API simultaneously is the recommended approach because it maximizes coverage. The Pixel captures conversions from users whose browsers allow tracking, while CAPI captures everything server-side. But this creates a problem: the same conversion can be reported by both sources, leading to double counting.

Event deduplication solves this by telling Meta when two events represent the same conversion. Meta automatically deduplicates events that share the same event_id and event_name within a 48-hour window. When both your Pixel and CAPI report events with matching identifiers, Meta counts it only once. This is a common issue where ad platforms take credit for the same conversion.

Why deduplication matters: Without it, your conversion metrics inflate artificially. If 100 actual conversions get reported as 150 because some were counted twice, your cost per conversion appears better than reality. This leads to poor optimization decisions and inaccurate performance analysis.

Implementing deduplication requires coordination between your browser-side and server-side code. When a conversion occurs, generate a unique event_id using a UUID or similar random identifier generator. Pass this ID to both your Pixel code and your CAPI implementation.

On the browser side, include the event_id parameter when firing your Pixel event. If you are using Meta's standard Pixel code, this looks like adding eventID: 'your-unique-id' to your fbq track call. The exact syntax depends on how you implemented your Pixel, but the concept remains the same: include the event_id with every conversion event.

On the server side, include the same event_id in the event object you send via CAPI. The event_id field sits at the same level as event_name and event_time in your JSON payload. Make sure the ID matches exactly what your browser sent, including capitalization and format.

Use consistent naming for your events across both sources. If your Pixel fires a "Purchase" event, your CAPI event must also be named "Purchase" with the same capitalization. Meta treats "Purchase" and "purchase" as different events and will not deduplicate them even with matching event_ids.

Verify success by checking the Events Manager Diagnostics tab after implementing deduplication. Meta shows you how many events were deduplicated, confirming that your matching logic works correctly. If you see no deduplicated events despite running both Pixel and CAPI, your event_id values are not matching properly.

Some conversion flows make deduplication tricky. For example, if a user completes a purchase on your website but the confirmation happens via email link, coordinating the event_id between page load and email click requires careful planning. In these cases, store the event_id in your database tied to the order or lead, then retrieve it when the final conversion fires.

Document your deduplication strategy clearly so future developers understand how it works. When troubleshooting conversion discrepancies months later, knowing whether deduplication is functioning correctly saves hours of investigation.

Step 6: Test Your Events Using the Test Events Tool

Before sending live conversion data, verify your implementation works correctly using Meta's Test Events tool. This tool lets you send events that appear in a special testing interface without affecting your production analytics or ad optimization.

Access the Test Events tab in Events Manager by selecting your pixel and clicking the "Test Events" option in the left sidebar. Meta displays a unique test event code that looks like a random string of characters. This code identifies events as test traffic.

Include this test_event_code parameter in your CAPI events during testing. Add it at the same level as your data array in the JSON payload. Events sent with this code appear in the Test Events interface but do not flow into your standard analytics or attribution.

Send a few test conversions through your implementation. If you built a custom integration, trigger the conversion flow in your development environment. If you are using a partner integration, use their testing tools to simulate events. Watch the Test Events interface in Events Manager to confirm your events arrive.

When events appear in the Test Events tool, Meta shows you detailed information about each one. You can see all the parameters you sent, whether required fields are present, and most importantly, your Event Match Quality score. If you encounter issues, our guide on how to fix Facebook Conversion API problems can help.

Event Match Quality is Meta's scoring system that rates how well your customer parameters enable matching between events and Facebook users. The score ranges from Poor to Great, with specific ratings for each event. Higher match quality leads to better ad optimization because Meta can more accurately attribute conversions to specific users and campaigns.

Check which parameters are contributing to your match quality score. Meta breaks down the score by showing which identifiers (email, phone, external_id, etc.) were successfully matched. If your score is Poor or OK, you need to include additional customer parameters to improve it.

Troubleshoot common issues using the diagnostic information Test Events provides. If required fields are missing, Meta highlights exactly which ones. If your event_time formatting is wrong, the tool shows the error. If you forgot to hash user_data parameters, Meta flags that too.

Pay attention to timestamp formatting, which causes frequent issues. The event_time must be a Unix timestamp (seconds since January 1, 1970), not an ISO date string or milliseconds. If you are seeing timestamp errors, verify your server is generating Unix timestamps correctly.

Verify your hashing implementation by sending test events with known values. If you hash "test@example.com" and see a match quality contribution from email, your hashing works. If not, check that you are converting to lowercase and removing spaces before hashing with SHA-256.

Test multiple event types if you are tracking more than just purchases. Send a Lead event, an AddToCart event, and a Purchase event to confirm all your conversion types work properly. Each event type might pull data from different parts of your application, so testing comprehensively prevents surprises in production.

Once your test events show Good or Great match quality scores and all required parameters are present, you are ready to remove the test_event_code and start sending production events. Keep the Test Events tab open for the first few hours of production traffic to monitor for any unexpected issues.

Step 7: Monitor Performance and Optimize Your Event Match Quality

With CAPI live in production, ongoing monitoring ensures your implementation continues working correctly and identifies opportunities for improvement. Event Match Quality is your primary metric for tracking CAPI effectiveness.

Review your Event Match Quality score in Events Manager regularly. Navigate to your pixel, click on the Overview tab, and look for the Event Match Quality section. Meta displays an aggregate score across all your events and individual scores for each event type.

Aim for Good or Great ratings on all your conversion events. If you are seeing OK or Poor scores, you are missing opportunities to improve ad optimization. Each additional customer parameter you include increases the likelihood Meta can match your server-side events to Facebook users. Learn how to improve Facebook ads conversion tracking for better results.

The most impactful parameters for improving match quality are email, phone, and external_id. If you are only sending one of these, work with your development team to capture and include the others. Even if you do not collect phone numbers at checkout, you might have them in your CRM for existing customers.

Beyond the core identifiers, adding technical parameters like client_ip_address and client_user_agent helps. These do not require personal information but improve matching accuracy. Your web server logs typically contain both values, making them easy to include.

The fbp and fbc parameters deserve special attention. The fbp is the Facebook browser pixel cookie value, and fbc is the Facebook click ID from ad clicks. If you are running both Pixel and CAPI, your browser-side code can read these values and pass them to your server for inclusion in CAPI events. This creates a strong connection between browser and server data.

Monitor the Diagnostics tab for any errors or warnings in your event delivery. Meta flags issues like malformed requests, invalid parameters, or authentication failures. Address these promptly because failed events mean lost conversion data and degraded ad optimization.

Compare attributed conversions before and after CAPI implementation to measure improvement. In your Ads Manager, look at conversion metrics for campaigns that were running before and after you enabled CAPI. Many businesses see a 10-30% increase in attributed conversions simply from improved tracking accuracy, though specific results vary based on your audience and tracking gaps. Understanding how to sync conversion data to Facebook ads ensures your optimization algorithms receive complete information.

Watch for changes in your cost per conversion metrics. Better tracking accuracy might reveal that your actual cost per conversion is different than what browser-only tracking showed. This is not a problem with CAPI; it is CAPI revealing the truth that was hidden before.

Set up alerts for significant drops in event volume. If your server stops sending events due to an API issue, deployment problem, or expired credentials, you want to know immediately. Many businesses integrate their CAPI implementation with monitoring tools that alert them when event volume drops below expected thresholds.

Review your implementation quarterly to ensure it still aligns with your business needs. As you add new products, conversion types, or customer touchpoints, update your CAPI configuration to track them. Your event schema should evolve with your business.

Putting It All Together

With your Conversion API now configured, you have established a direct data pipeline between your server and Meta that browser limitations cannot interrupt. This server-side connection captures conversions that browser-based tracking misses, giving you more complete visibility into campaign performance.

Your setup checklist: Pixel ID documented and stored securely, access token generated and protected in environment variables, events configured with proper parameters including hashed user_data, deduplication enabled with consistent event_id values across Pixel and CAPI, and test events verified with Good or Great match quality scores.

Moving forward, regularly check your Event Match Quality score and add customer parameters when possible to improve matching rates. The difference between an OK score and a Great score directly impacts how well Meta can optimize your campaigns. Every additional identifier you include helps Meta connect your conversion data to actual users.

Monitor the Diagnostics tab weekly to catch any implementation issues early. Failed events mean lost data, and catching problems quickly minimizes the impact on your analytics and optimization. Set up monitoring alerts if possible so you know immediately when something breaks.

Remember that CAPI works best alongside Facebook Pixel, not as a replacement. The combination maximizes coverage by capturing conversions through both browser-based and server-side channels. Your deduplication setup ensures you get complete data without double counting.

For marketers managing multiple ad platforms and seeking unified attribution across all channels, tools like Cometly can streamline this process by handling server-side tracking and feeding enriched conversion data back to Meta and other platforms automatically. Instead of implementing CAPI separately for each ad platform, Cometly captures every touchpoint across your marketing funnel and syncs conversion data to all your ad accounts. The platform's AI analyzes performance across channels and provides recommendations on where to scale, taking the complexity out of cross-platform attribution.

The result is more accurate attribution, better ad optimization, and clearer visibility into which campaigns actually drive revenue. Your Meta campaigns can now optimize based on complete conversion data rather than the partial picture browser tracking provides. This leads to better targeting, improved ROAS, and more confident scaling decisions.

Ready to elevate your marketing game with precision and confidence? Discover how Cometly's AI-driven recommendations can transform your ad strategy. Get your free demo today and start capturing every touchpoint to maximize your conversions.