Conversions API Direct Integration Playbook English
Conversions API Direct Integration Playbook English
Direct
Integration
Playbook for
Developers
Introduction
Conversions API is a Facebook Business Tool that lets
you share key web and offline events, or customer
actions, directly from your server to Facebook’s.
Conversions API works with your Facebook pixel to help
improve the performance and measurement of your
Facebook ad campaigns. Table of contents
Preparation p.2
A direct Conversions API integration is a great choice for
businesses that have developer resources available, Implementing the API p.4
access to their server codebase, and need the ability to Send events p.5
customize their configuration, control what data they Add parameters to events p.6
share to Facebook and when they share it. Test events p.9
Verify events p.10
Alternatively, businesses that need faster and easier
Conversions API setups often use Facebook Business Troubleshoot and optimal configuration p.12
Partners that offer Conversions API as one of several Glossary and additional resources p.19
consolidated business solutions.
1. Preparation
Before you begin building your direct Conversions API integration, you’ll need a Facebook pixel, Business
Manager and access token.
• Make sure you have the Facebook pixel • To use the Conversions API, you need a
correctly implemented in your website Business Manager account
• We recommend that you use the same pixel • Business Manager is a Facebook tool that
for your browser and server events helps you organize and manage your business
• You use your Facebook username and password to sign into Business Manager
• Enter a name for your business, your name and work email address and click Next
Note
You can create only 2 Business Manager accounts. If you need more, please work with someone else in your
organization to create additional Business Manager accounts.
Conversions API: 3
Direct Integration Playbook
Access Token
• To use the Conversions API, you need an access token, which is passed as a parameter in each API call
• You can generate an access token through Events Manager (recommended) or, if you already have your
own app and your own system user, you can generate an access token inside Business Manager
• For either option, there is no need to go through App Review or to request any permissions
Generate access token in Events Manager Generate access token in Business Manager
Note
The “Generate access token” link is only visible to
users with developer privileges for the business.
The link is hidden from other users.
To create your payload from the Payload Once you are satisfied with your payload, decide
Helper tool, add your pixel ID under “Test this how to make your call.
Payload” and click on Send to Test Events
• You can use our Graph API Explorer or cURL
• You should be able to see the event on
• Independently on your call method, you should
Events Manager > Your Pixel > Test Events
call the /{pixel_id}/events endpoint and
• Learn more about the Test Events Tool attach the JSON data generated by the Payload
Helper tool
If you need additional guidance for completing your first API call, watch this video tutorial
Conversions API: 5
Direct Integration Playbook
3. Send events
The most important events to send using Best practices for upload times, batching,
Conversions API are your optimization events and timeouts:
(usually a conversion event like “purchase”). That
said, we recommend sending events throughout event_time should be sent as a Unix timestamp*
your purchase funnel (as advertisers often do with in seconds indicating when the actual event
the pixel). occurred.
• To send events from your server, make a POST • *Note: Unix timestamps are timezone agnostic
request to this API's /events edge from this path: • The delay between event_time and the time
https://graph.facebook.com/{API_VERSION} you send to Facebook should be as close to 0 as
/{PIXEL_ID}/events?access_token={TOKEN} possible, and no longer than 7 days (if longer than
• When you post to this edge, Facebook creates 7 days, we return an error for the entire request
new server events and process no events)
• Only matched and processed events can be used for ads attribution and ad delivery optimization
• The more customer information parameters you add, the more effective your customer information
may be at matching your server event to a Facebook account, which may improve campaign performance
Later in this guide (in the Event Match Quality (EMQ) score section), we describe how the parameters you
send can improve Event Match Quality—the better your EMQ score, the more effective your event may be at
matching to Facebook account. Only matched events can be used for targeting and optimization.
Note
“Hashing needed” indicates these fields contain personally identifiable information (PII). This data
must be hashed with SHA256 and UTF-8 encoding. We do not accept this data unhashed and reject
the entire event.
Recommended parameters (events missing these parameters will still be processed, but may not be
effectively matched and deduplicated):
• external_id
external id is a string that represents a user on an advertiser’s system, like loyalty membership
IDs, user IDs, and external cookie IDs. You can send one or more external_ IDs for a given event and
we try to match it to someone on Facebook
• event_id
This ID can be any unique string chosen by the advertiser. event_id is used to deduplicate events
sent by both Facebook Pixel and Conversions API. event_name is also used in deduplication
The Limited Data Use feature gives businesses more control over how their data is used in our systems,
for example, to support businesses in complying with the California Consumer Privacy Act (CCPA).
Learn more about data processing options for users in California on Facebook for Developers.
Conversions API: 8
Direct Integration Playbook
Parameters used as
Deduplication Keys
Because we recommend using a pixel + Conversions
API connection for as many of your events as
possible, these redundant events require
deduplication by using a consistent event naming
convention and one of the following sets of
deduplication keys:
Option A (Recommended)
Deduplication method
Events received within 48 hours of one another
containing the same event_name, same
event_id and sent to the same pixel ID are
considered duplicates, and we discard the latter
of the two.
Deduplication Keys
event_name
event_id
Option B
Deduplication method
You must use event_name along with the fbp
and/or external_id consistently across
browser and server events. A browser event must
arrive first and if a server event is received before
the corresponding browser event, it may be
double counted. Because of these limitations, we
recommend Option A.
Deduplication Keys
event_name
fbp and/or external_id
event_time
Conversions API: 9
Direct Integration Playbook
5. Test events
Check that events are processed and deduplicated correctly using the Test Events tool.
• Go to Events Manager > Data Sources > Your Pixel > Test Events
• The Test Events tool generates a test ID
• Send the test ID as a test_event_code parameter to start seeing event activity appear in the Test
Events window
Your test events should show up in the Test Events tool within 30 seconds after you send a test event.
• If they don’t, make sure your payload is structured correctly using the Payload Helper tool
• Test information remains in the Test Events tool for 24 hours or until you clear it by clicking “Clear
Activity”
Note
Events sent with test_event_code are processed and used for targeting and ads measurement.
Conversions API: 10
Direct Integration Playbook
6. Verify events
After you start sending events, you should be able to verify them within 20 minutes.
• Go to Events Manager > Data Sources > click on the pixel corresponding to the PIXEL_ID in your
POST request
• For each pixel, go to Overview > Events > Connection Method
• Under “Connection Method,” you’ll see “Browser,” “Server” or “Browser + Server”
Best practice
We recommend using a “Browser + Server” connection method for as many of your events as possible.
Events with a browser-only connection are more susceptible to being missed or unattributed due to a
customer’s poor internet connection, page load errors and 3rd party cookie deprecation by web browsers.
Best practice
Click on each event to see more details and recent activity, such as:
• If invalid, a 4xx HTTP response code is returned, with minimal error details in the response body
• You can get more detailed information for debugging any request by making a POST request to
/events/?trace= in Graph API Explorer
• Options for trace include:
1 - Error
2 - Info
3 - Debug
Best practice
Monitor your Conversions API connection by visiting the Diagnostics tab in Events Manager regularly. Hover
over the "!" icon to learn more about an issue and recommendations to improve it.
Diagnostic message in
Context Proposed resolution
Events Manager
How long ago your event occured (ideally, 0 minutes, i.e. real time,
Data freshness
and no longer than 7 days)
Note
See below for additional details about using these criteria for achieving an optimal Conversions API configuration.
Conversions API: 14
Direct Integration Playbook
Optimal configuration
Follow the below recommendations to optimize your configuration, which may improve your ad performance.
Event Redundancy
For the most reliable data connection, we recommend using a “browser + server” connection
method for all events.
Event Deduplication
As recommended, events are shared redundantly using a “browser + server connection,” and
therefore, our system must understand that these redundant events describe a single customer
action (event instance) by deduplicating them.
Conversions API). Some events may not be counted here due to errors
Events received using Conversions API should be at least equal if not higher than events
received using Browser Pixel
i Events Processed: The number of events received from browsers and servers excluding any
duplicates. These are the events used for measurement and optimization (Events Processed =
Events Received – Events Deduplicated)
i Events Deduplicated: The number of events received and identified as duplicates and therefore
not processed
Conversions API: 16
Direct Integration Playbook
3. Overlap %:
• Overlap represents the percentage of
Deduplication Keys received using both
Pixel and Conversions API
Data Freshness
Terms of Use
Facebook Business Tools Terms
https://www.facebook.com/legal/terms/businesstools
Best Practices
Best Practices for Conversions API
https://developers.facebook.com/docs/marketing-api/conversions-api/best-practices
Best Practices for Privacy and Data Use for Facebook Business Tools
https://www.facebook.com/business/help/PrivacyBestPractices
Cookie Consent
https://developers.facebook.com/docs/app-events/cookies/
Conversions API: 20
Direct Integration Playbook
Batch Requests
https://developers.facebook.com/docs/marketing-api/conversions-api/using-the-api#batch-requests
Recommended and Maximum Delay Times for Web and Offline Events
https://www.facebook.com/business/help/RecommendedDelayTimes
Parameters
https://developers.facebook.com/docs/marketing-api/conversions-api/parameters
Hashing
https://developers.facebook.com/docs/marketing-api/conversions-api/using-the-api#hashing
Troubleshooting
Troubleshoot the Facebook Event Setup Tool for Web
https://www.facebook.com/business/help/TroubleshootEventSetupTool
Rate limiting
https://developers.facebook.com/docs/marketing-apis/rate-limiting
Error codes
https://developers.facebook.com/docs/marketing-api/error-reference
Throttling errors
https://developers.facebook.com/docs/marketing-apis/rate-limiting#throttlingerrors
Dropped events
https://developers.facebook.com/docs/marketing-api/conversions-api/using-the-api#dropped-events
Training
Webinar: How to Use the Conversions API: A Developer's Guide
https://www.facebook.com/business/m/sessionsforsuccess/conversions-api
Support
Developer Support
https://developers.facebook.com/support/