Background
The system is pivoted onto three things:
- Ad account - via which Ads are created, run and analysed. Represent via Ad Account Id
- User - whose access token is used by App to manage ads on his behalf ; Ensure that this user has admin/advertiser role in the Ad account and developer or Admin Role in the FB App.
- FB App - to allow others to access ad account via APIs on behalf of user using his/her access token
Create an App
Go to https://developers.facebook.com/apps/ and click on Add a new App
Add a display name and the email ID which is associated with your Facebook Business Account. Click on Create App ID
You will be redirected to Add a Product page. Scroll in the list and find Marketing API. Click on Set Up.
An App dashboard will open with Marketing API added in Product Section.
Use an existing App
If you already have an existing app that you want to use, go to https://developers.facebook.com/apps/ and select the FB app that you want to use.
The App dashboard will open. Make sure that Marketing API is added under this app. If not, click the in the left pane and add Marketing API.
Retrieve Access Token
Once you have selected your app and have Marketing API added under the products, Click on Tools under Marketing API.
From the list, choose ads_management ; ads_read . Click on Get Token
Note
Make sure to copy the token and save it as you won't be able to retrieve it later.
Add an Ad Account
In the Marketing API, go to Settings
Select your Ad-account Id in the dropdown present in Business Manager heading.
The Facebook Business Settings page will open. Make sure that the correct Business account is selected in the dropdown.
From the left panel, go to Accounts > Ad Accounts. Or you can directly go to https://business.facebook.com/settings/ad-accounts
On the right hand side - in the Ad Accounts section - click
Select the first option - Add an ad account
It will open a new pop-up: Add an ad account. Enter your Ad account ID and click on Add an ad account button on the bottom right of this pop-up.
Get the Ad Account ID
Go to To https://business.facebook.com/settings/ad-accounts. If asked, Select the Business account you want to use.
Under Ad Accounts, select the Ad Account you want to use.
The ID is present under the Ad Account name, as shown in the image below.
Now you need to share two things with us:
- Ad Account Id
- Access token
Post Setup
Once the basic setup is done, you can start creating the audience (For initial few days, you should only send around 1k-2k request per day with a request per minute rate of 300)
To create Connector Campaign, please ensure that:
- You have Ad Account Id & Access Token
Create Blank Audience
You can use any API tools (like Postman) to create a blank audience on Facebook. You need to have account id and access token with you.
You need to post to URL: https://graph.facebook.com/v5.0/act_12345678912345678/customaudiences where 12345678912345678 is your Ad Account Id. Replace it before hitting the URL. Here is a sample snapshot of the API request that can be made via Postman
Additionally, put the following keys in the BODY
name: MOE_SampleAudience
subtype: CUSTOM
description: any_audiencedescription
access_token: EAAHZCclz4YJABAEHvW2f4WWpoRfuQsYEEXS7ZBG4Nmg2jfXdWpqt69LR5VjrJRwy9ZBpvYs19uIhT4SjZAixeEUIA7UESQeTNXMSGJLkxLjZCI1In7mqdZBVd8PT4UdV8jkUQFoWoyqUUwDu5PUDk46sxjCI8gBCRcqesVieHKZBCZB7CZCiVmFtq
customer_file_source: USER_PROVIDED_ONLY
Once API request is successful, you will get an audience id like 6095029787986 or 6073172490567 or any similar values in API response.
Add User to FB Audience
Allows you to add users blank FB Audience created above. You would need to create a connector campaign to add users to your FB audience as per steps mentioned below:
Step 1
Choose your targeting criteria and addition type - batch or triggered
Step 2
Webhook URL:
https://graph.facebook.com/v5.0/6073172490567/users where 6073172490567 is the blank audience Id, generated in the step above.
Request Type:
POST
Headers:
Content-Type - application/json
Body:
Use the body type as JSON. In JSON Body, we will use two K-V pairs:
Key 1:
Key Name: access_token
Key Value: Access token that you saved above
Key 2:
Key Name: payload
Key Value: { "schema": "MOBILE_ADVERTISER_ID", "data": [ "04b4c1ac-8d3c-451d-8d8e-c3fff2e89274" ] }
In place of 04b4c1ac-8d3c-451d-8d8e-c3fff2e89274, choose the attribute having Google Advertiser Id or IDFA for your customers. You can find the attribute using @ .
Currently we support matching only by Mobile Advertiser Id.
Step 3
To save making duplicate calls, use attribute using Google Advertiser Id as De-dup key.
Limit your requests to 100-500 requests per minute (rpm) as Facebook throttles high throughput for new integrations.
Note: To remove (Delete) users from FB audience once they have achieved the conversion goal, create another Connector Campaign as mentioned below.
DELETE User from FB Audience
Allows you to remove users that have been added to FB Audience. To delete, create another Connector Campaign as per the steps below.
Step 1
Choose your targeting criteria and deletion send type - at once or triggered
Step 2
Webhook URL
https://graph.facebook.com/v3.1/6073172490567/users where 6073172490567 is the audience Id from which the user has to be deleted
Request Type
DELETE
BODY
Use the body type as JSON Data. In Json, we use two Key-Value pairs as mentioned below.
Key 1:
Key Name: access_token
Key Value: Access token that you saved here
Key 2:
Key Name: payload
Key Value: { "schema": "MOBILE_ADVERTISER_ID", "data": [ "04b4c1ac-8d3c-451d-8d8e-c3fff2e89274" ] }
In place of 04b4c1ac-8d3c-451d-8d8e-c3fff2e89274, choose the attribute having Google Advertiser Id or IDFA for your customers. You can find the attribute using @ .
Step 3
To save making duplicate calls, use attribute using Google Advertiser Id as De-dup key.
Limit your requests to 100-500 requests per minute (rpm) as Facebook throttles high throughput for new integrations.