Beginning February 15th, 2021, website events shared using Conversions API will require the following data parameters: client_user_agent
, action_source
, and event_source_url
, while non-web events will require only action_source
. These parameters contribute to improving the quality of events used for ad delivery and may improve campaign performance.
Before implementing the conversions API, make sure you have all the prerequisites listed on the main conversions API document. In this page, you learn to:
The conversions API is based on Facebook's Marketing API, which was built on top of our Graph API. Marketing and Graph APIs have different version deprecation schedules. Our release cycle is aligned with the Graph API, so every version is supported for at least two years. This exception is only valid for conversions API.
Conversions API: DocumentationParametersTo send new events, make a POST
request to this API's /events
edge from this path: https://graph.facebook.com/{API_VERSION}/{PIXEL_ID}/events?access_token={TOKEN}
. When you post to this edge, Facebook creates new server events.
curl -X POST \
-F 'data=[
{
"event_name": "PageView",
"event_time": 1611320192,
"user_data": {
"fbc": "fb.1.1554763741205.AbCdEfGhIjKlMnOpQrStUvWxYz1234567890",
"fbp": "fb.1.1558571054389.1098115397",
"em": "309a0a5c3e211326ae75ca18196d301a9bdbd1a882a4d2569511033da23f0abd"
}
}
]' \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v9.0/<PIXEL_ID>/events
Attach your generated secure access token using the access_token
query parameter to the request. You can also use Graph API Explorer to POST
to the /<pixel_id>/events
endpoint.
An example request body looks like this:
{
"data": [
{
"event_name": "Purchase",
"event_time": 1611319592,
"event_id": "event.id.123",
"event_source_url": "http:\/\/jaspers-market.com\/product\/123",
"user_data": {
"client_ip_address": "192.19.9.9",
"client_user_agent": "test ua",
"em": "309a0a5c3e211326ae75ca18196d301a9bdbd1a882a4d2569511033da23f0abd",
"fbc": "fb.1.1554763741205.AbCdEfGhIjKlMnOpQrStUvWxYz1234567890",
"fbp": "fb.1.1558571054389.1098115397"
},
"custom_data": {
"value": 100.2,
"currency": "USD",
"content_ids": [
"product.id.123"
],
"content_type": "product"
},
"opt_out": false
},
{
"event_name": "Purchase",
"event_time": 1611319592,
"user_data": {
"client_ip_address": "192.88.9.9",
"client_user_agent": "test ua2"
},
"custom_data": {
"value": 50.5,
"currency": "USD"
},
"opt_out": true
}
]
}
See this video for help completing your first API call. For prework information see Create a Business Manager and Create a Facebook Pixel in Business Manager.
You can use open source code-generator Swagger to generate client side API code for our conversions API. The generated code handles the API calls, exception handling, and retries.
To use Swagger, you need Java (version 7 or higher). Learn more about our Swagger API integration.
Network errors or malformed requests may cause events to be dropped.
event_time
is the event transaction time. It should be sent as a Unix timestamp in seconds indicating when the actual event occurred. The specified time may be earlier than the time you send the event to Facebook. This is to enable batch processing and server performance optimization.
event_time
can be up to 7 days before you send an event to Facebook. If any event_time
in data
is greater than 7 days in the past, we return an error for the entire request and process no events.
You can send up to 1,000 events in data
. However, for optimal performance, we recommend you send events as soon as they occur and ideally within an hour of the event occurring. If any event you send in a batch is invalid, we reject the entire batch.
Please check our customer information parameters page to see which parameters should be hashed before they are sent to Facebook. If you are using one of our Business SDKs, the hashing is done for you by the SDK.
Learn more about three specific Business SDK features designed especially for Conversions API users: Asynchronous Requests, Concurrent Batching, and HTTP Service Interface. Minimum language version required to use these features:
Business SDK support for PHP 5 has been deprecated since January 2019. Please upgrade to PHP 7 to use the Business SDK.
If you must use PHP 5, consider using our Swagger implementation.
After you send your events, confirm that we have received them in Events Manager:
PIXEL_ID
in your POST
request. For more information see Business Help Center: Navigate Events Manager.You can verify that your server events are received correctly by Facebook by using the Test Events feature in Events Manager. To find the 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.
Events sent with test_event_code
are not dropped. They flow into Events Manager and are used for targeting and ads measurement purposes.
Here's an example of how the request should be structured:
Here's an example of how the request appears in Graph API Explorer:
Your server events appear in the Test Events window once the request is sent.
data_processing_options
, data_processing_options_country
, and data_processing_options_state
inside each event within the data parameter of your events.
{ "data": [ { "event_name": "Purchase", "event_time": <EVENT_TIME>, "user_data": { "em": "<EMAIL>" }, "custom_data": { "currency": "<CURRENCY>", "value": "<VALUE>" }, "data_processing_options": [] } ] }To enable LDU and specify user geography:
{ "data": [ { "event_name": "Purchase", "event_time": <EVENT_TIME>, "user_data": { "em": "<EMAIL>" }, "custom_data": { "currency": "<CURRENCY>", "value": "<VALUE>" }, "data_processing_options": ["LDU"], "data_processing_options_country": 1, "data_processing_options_state": 1000 } ] }To enable LDU with geolocation (this works for Server-side API provided client IP address is provided):
{ "data": [ { "event_name": "Purchase", "event_time": <EVENT_TIME>, "user_data": { "em": "<EMAIL>", "client_ip_address": "256.256.256.256" }, "custom_data": { "currency": "<CURRENCY>", "value": "<VALUE>" }, "data_processing_options": ["LDU"], "data_processing_options_country": 0, "data_processing_options_state": 0 } ] }
.csv
file. In this case, add Data Processing Options, Data Processing Country, and Data Processing State as columns inside your file. More information about this can be found in the upload user interface.
Learn more about Data Processing Options.
The Marketing API has its own rate-limiting logic and is excluded from all the Graph API rate limitations. So if you make a Marketing API call, it won't be calculated into the Graph API throttling.
There is no specific rate limit for conversions API. Conversions API calls are counted as Marketing API calls. The only limitation is that you can send us up to 1,000 events at a time. See Send Requests for more information.
Marketing API Rate Limiting