This document shows you how to create an A/B test for reels and videos published on a Facebook Page.
You can run up to 50 tests at once with a minimum of 2 posts and a maximum of 4 posts per test.
You need the following:
CREATE_CONTENT
task on the Pagepages_manage_engagement
pages_show_list
pages_manage_posts
pages_read_engagement
pages_read_user_content
To create an A/B test, send a POST
request to the /
PAGE
/ab_tests
endpoint, where PAGE
is the ID for the Facebook Page, and include the following parameters:
Required
control_video_id
– the ID for the video that, in the event of a tie, will be selected as the winning video description
– the description for your experimentexperiment_video_ids
– the IDs for the videos you are comparingname
– the name for your experimentoptimization_goal
– the goal of your experiment must be one of the following:
|
|
|
Optional
duration
– the length of time, in seconds, to run the test
scheduled_experiment_timestamp
– the UNIX timestamp for the time to start the test,
Formatted for readability. Replace bold, italics values, such as PAGE
, with your values.
curl -X POST "https://graph.facebook.com/v21.0
/YOUR_PAGE_ID/ab_tests"
-H "Content-type: application/json"
-d '{
"name": "YOUR_TEST_NAME",
"description": "YOUR_TEST_DESCRIPTION",
"optimization_goal": "YOUR_OPTIMIZATION_GOAL",
"experiment_video_ids": [YOUR_EXPERIMENTAL_VIDEO_ID_1, YOUR_EXPERIMENTAL_VIDEO_ID_2],
"control_video_id": YOUR_EXPERIMENTAL_VIDEO_ID_1_AS_CONTROL,
"duration": 1800,
}'
On success your app will receive a JSON response with the ID for your A/B test.
{ "id": "AB_TEST_ID" }
You can get data about an A/B test during the experiment or after it has concluded.
To get data about a specific A/B test, send a GET
request to the /AB_TEST_ID
enpoint where AB_TEST_ID
is the ID for the test you are interested in.
curl -i -X GET "https://graph.facebook.com/AB_TEST_ID"
On success your app will receive a JSON response with details about the experiment such as the name, goal, IDs for the videos, published status, videos insights for each test video, and a declaration for which video performed the best. In the example here, EXPERIMENTAL_VIDEO_ID_1 performed the best.
{ "id": YOUR_AB_TEST_ID, "name": "YOUR_AB_TEST_NAME", "description": "YOUR_AB_TEST_DESCRIPTION", "optimization_goal": "REELS_PLAYS", "experiment_video_ids": [YOUR_EXPERIMENTAL_VIDEO_ID_1, YOUR_EXPERIMENTAL_VIDEO_ID_2], "control_video_id": VIDEO_ID_1_AS_CONTROL, "publish_status": "LIVE", "creation_time": "1686665092", "updated_time": "1686665092", "scheduled_experiment_timestamp": "1686665092", "test_insights": { "timestamp": "1686665092", "videos": { YOUR_EXPERIMENTAL_VIDEO_ID_1: { "plays": 10, "impressions": 1, "fan_impressions": 1, "link_clicks": 1, "comments": 1, "shares": 1, "reactions": 1, "video_views_60s": 1, "video_views_3s": 1, "video_views_15s": 1, "avg_video_views": 1, "video_views": 1, "instream_ads_earnings": 1, "avg_time_watched": 1, "video_retention_graph": { "0": 1, "1": 1, "2": 0.5, "3": 0.2 } } YOUR_EXPERIMENTAL_VIDEO_ID_2: { "plays": 5, "impressions": 1, "fan_impressions": 1, "link_clicks": 1, "comments": 0, "shares": 0, "reactions": 1, "video_views_60s": 1, "video_views_3s": 1, "video_views_15s": 1, "avg_video_views": 1, "video_views": 1, "instream_ads_earnings": 0, "avg_time_watched": 1, "video_retention_graph": { "0": 1, "1": 1, "2": 0.5, "3": 0.2 } } }, "declared_winning_video": YOUR_EXPERIMENTAL_VIDEO_ID_1, } }
To get a list of all A/B tests conducted on your Facebook Page, send a GET
request to the /***PAGE***/ab_tests
endpoint where PAGE
is the ID for the Page you are interested in. Add the since
and unti
parameters to get data for tests run during a specific time period.
Note: When using the since
and until
parameters in your GET
request, the date for until
must be a date after the date for since
. For example, if since
is 2023-01-31, until
must be after 2023-01-31. You can use both parameters, or one or the other. Date formats can be any of the following:
today
, yesterday
Epoch timestamps (1676057525
)
dd mmm yyyy (31 jan 2023
) or dd-mm-yyyy (31-1-2023
)
curl -X GET "https://graph.facebook.com/v21.0
/PAGE/ab_tests"
On success your app receives a JSON response with an array of test objects.
{ "data": [ ... {AB_TEST_RESPONSE_OBJECT_1}, ... {AB_TEST_RESPONSE_OBJECT_2}, ... {AB_TEST_RESPONSE_OBJECT_3} ], "cursors": { "before":"QVFIUkxLWWtMb3BSQV91aF81NkN4c1RYczJZAQ0NQOHpQ", "after":"QVFIUkxLWWtMb3BSQV91aF81NkN4c1RYczJZAQ0NQOH" } }
You can delete an A/B test once it has concluded.
To delete an A/B test, send a DELETE
request to the AB_TEST_ID
endpoint where ID is the ID for the A/B test you want to delete.
curl -X DELETE "https://graph.facebook.com/v21.0
/AB_TEST_ID"
Note that the posts in the A/B test will not be deleted.
Endpoint | Description |
---|---|
| Create and read A/B tests for a specific Facebook Page |
| A specific A/B test |