Build an audience of your customers, website visitors, mobile app visitors or people similar to them. To add or remove users from a Custom Audience, please see the Custom Audience User guide.
To use Custom Audiences, the Business’ users must first sign our Terms Of Service contracts. Learn more about Custom Audience Terms Of Service.
Custom audiences allow advertisers to target their ads to a specific set of people with whom they have already established a relationship on/off Facebook. Audiences can be defined by either email address, Facebook UIDs, phone numbers, names, date of birth, gender, locations, app user IDs, Apple's Advertising Identifier (IDFA), Android's advertising ID or by a combination of rules used to identify users who took specific actions on your website.
When utilizing Facebook UIDs please ensure you comply with Section II of the Platform Policies. An advertiser must accept Custom Audience's terms of service in order to use the product. You can query which terms a given account accepted by checking the fieldtos_accepted of a given ad account. You can find more information at the ad account node documentation.
By audience ID:
use FacebookAds\Object\CustomAudience;
$custom_audience = new CustomAudience(<CUSTOM_AUDIENCE_ID>);
$custom_audience->read();from facebookads.adobjects.customaudience import CustomAudience
audience = CustomAudience('<CUSTOM_AUDIENCE_ID>')
audience.remote_read()CustomAudience customAudience2 = new CustomAudience(<CUSTOM_AUDIENCE_ID>, context).get()
.execute();curl -G \
-d 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v2.11/<CUSTOM_AUDIENCE_ID>By ad account edge:
Note: Some types of custom audiences are not available through the ad account edge (e.g. Study Audience) however you can get their details by querying the CUSTOM_AUDIENCE_ID directly.
GET /v6.0/<CUSTOM_AUDIENCE_ID>/ HTTP/1.1
Host: graph.facebook.com/* PHP SDK v5.0.0 */
/* make the API call */
try {
// Returns a `Facebook\FacebookResponse` object
$response = $fb->get(
'/<CUSTOM_AUDIENCE_ID>/',
'{access-token}'
);
} catch(Facebook\Exceptions\FacebookResponseException $e) {
echo 'Graph returned an error: ' . $e->getMessage();
exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
echo 'Facebook SDK returned an error: ' . $e->getMessage();
exit;
}
$graphNode = $response->getGraphNode();
/* handle the result *//* make the API call */
FB.api(
"/<CUSTOM_AUDIENCE_ID>/",
function (response) {
if (response && !response.error) {
/* handle the result */
}
}
);/* make the API call */
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/<CUSTOM_AUDIENCE_ID>/",
null,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
/* handle the result */
}
}
).executeAsync();// For more complex open graph stories, use `FBSDKShareAPI`
// with `FBSDKShareOpenGraphContent`
/* make the API call */
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
initWithGraphPath:@"/<CUSTOM_AUDIENCE_ID>/"
parameters:params
HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
id result,
NSError *error) {
// Handle the result
}];curl -X GET -G \
-d 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v6.0/<CUSTOM_AUDIENCE_ID>/| Parámetro | Descripción |
|---|---|
ad_account_idnumeric string | ID of the recipient ad account in which custom audience is used. |
| Campo | Descripción |
|---|---|
idnumeric string | Custom audience ID |
account_idnumeric string | Ad Account ID |
approximate_countint32 | Approximate number of people in this audience. A call for this field returns |
customer_file_sourcestring | Source of customer information in the uploaded file |
data_source | JSON dictionary of |
delivery_status | JSON dictionary of
|
descriptionstring | Custom audience description |
external_event_source | Read-only JSON dictionary with key |
is_value_basedbool | Whether the audience is used to seed value based lookalike |
lookalike_audience_idslist<numeric string> | The IDs of the lookalike audiences generated from this audience |
lookalike_spec | Generated only when the subtype is |
namestring | Custom audience name |
operation_status | JSON dictionary of
|
opt_out_linkstring | Your opt-out URL so people can choose not to be targeted |
permission_for_actionsAudiencePermissionForActions | JSON dictionary of permissions (string) to boolean value if the custom audience has that permission |
pixel_idnumeric string | ID of the pixel which is collecting events for this Website Custom audience |
retention_daysint32 | Number of days to keep the user in this cluster. You can use any value between 1 and 180 days. Defaults to forever, if not specified. Only available for Customer File Custom Audience, including Custom Audiences created from CRM data. |
rulestring | Audience rules to be applied on the referrer URL |
rule_aggregationstring | Aggregation on top of the rule, examples of aggregations include: count, sum etc |
sharing_statusCustomAudienceSharingStatus | Sharing status of this custom audience for the ad account |
subtypestring | Type of custom audience, derived from original data source. |
time_content_updatedunsigned int32 | Last update of people in this custom audience, this field is only supported for Customer List Custom Audiences. |
time_createdunsigned int32 | Creation time |
time_updatedunsigned int32 | Last time this audience metadata was updated |
| Perímetro | Descripción |
|---|---|
The ad account ids associated with this custom audience | |
Ads that are using this custom audience | |
Data upload sessions of this custom audience | |
List of Ad Accounts and Businesses this Audience is shared to |
| Error | Descripción |
|---|---|
| 80003 | There have been too many calls to this ad-account. Wait a bit and try again. For more info, please refer to https://developers.facebook.com/docs/graph-api/overview/rate-limiting. |
| 100 | Invalid parameter |
| 200 | Permissions error |
| 190 | Invalid OAuth 2.0 Access Token |
Create a blank audience:
use FacebookAds\Object\CustomAudience;
use FacebookAds\Object\Fields\CustomAudienceFields;
use FacebookAds\Object\Values\CustomAudienceSubtypes;
$audience = new CustomAudience(null, 'act_<AD_ACCOUNT_ID>');
$audience->setData(array(
CustomAudienceFields::NAME => 'My new CA',
CustomAudienceFields::SUBTYPE => CustomAudienceSubtypes::CUSTOM,
CustomAudienceFields::DESCRIPTION => 'People who bought from my website',
));
$audience->create();from facebookads.adobjects.customaudience import CustomAudience
audience = CustomAudience(parent_id='act_<AD_ACCOUNT_ID>')
audience[CustomAudience.Field.subtype] = CustomAudience.Subtype.custom
audience[CustomAudience.Field.name] = 'My new CA'
audience[CustomAudience.Field.description] = 'People who bought on my website'
audience.remote_create()CustomAudience customAudience = new AdAccount(act_<AD_ACCOUNT_ID>, context).createCustomAudience()
.setName("My new CA")
.setSubtype(CustomAudience.EnumSubtype.VALUE_CUSTOM)
.setDescription("People who bought from my website")
.execute();curl \
-F 'name=My new CA' \
-F 'subtype=CUSTOM' \
-F 'description=People who bought from my website' \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v2.11/act_<AD_ACCOUNT_ID>/customaudiencescustomaudiences edge from the following paths: POST /v6.0/act_<AD_ACCOUNT_ID>/customaudiences HTTP/1.1
Host: graph.facebook.com
name=My+new+Custom+Audience&subtype=CUSTOM&description=People+who+purchased+on+my+website&customer_file_source=USER_PROVIDED_ONLY/* PHP SDK v5.0.0 */
/* make the API call */
try {
// Returns a `Facebook\FacebookResponse` object
$response = $fb->post(
'/act_<AD_ACCOUNT_ID>/customaudiences',
array (
'name' => 'My new Custom Audience',
'subtype' => 'CUSTOM',
'description' => 'People who purchased on my website',
'customer_file_source' => 'USER_PROVIDED_ONLY',
),
'{access-token}'
);
} catch(Facebook\Exceptions\FacebookResponseException $e) {
echo 'Graph returned an error: ' . $e->getMessage();
exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
echo 'Facebook SDK returned an error: ' . $e->getMessage();
exit;
}
$graphNode = $response->getGraphNode();
/* handle the result *//* make the API call */
FB.api(
"/act_<AD_ACCOUNT_ID>/customaudiences",
"POST",
{
"name": "My new Custom Audience",
"subtype": "CUSTOM",
"description": "People who purchased on my website",
"customer_file_source": "USER_PROVIDED_ONLY"
},
function (response) {
if (response && !response.error) {
/* handle the result */
}
}
);Bundle params = new Bundle();
params.putString("name", "My new Custom Audience");
params.putString("subtype", "CUSTOM");
params.putString("description", "People who purchased on my website");
params.putString("customer_file_source", "USER_PROVIDED_ONLY");
/* make the API call */
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/act_<AD_ACCOUNT_ID>/customaudiences",
params,
HttpMethod.POST,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
/* handle the result */
}
}
).executeAsync();// For more complex open graph stories, use `FBSDKShareAPI`
// with `FBSDKShareOpenGraphContent`
NSDictionary *params = @{
@"name": @"My new Custom Audience",
@"subtype": @"CUSTOM",
@"description": @"People who purchased on my website",
@"customer_file_source": @"USER_PROVIDED_ONLY",
};
/* make the API call */
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
initWithGraphPath:@"/act_<AD_ACCOUNT_ID>/customaudiences"
parameters:params
HTTPMethod:@"POST"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
id result,
NSError *error) {
// Handle the result
}];curl -X POST \
-F 'name="My new Custom Audience"' \
-F 'subtype="CUSTOM"' \
-F 'description="People who purchased on my website"' \
-F 'customer_file_source="USER_PROVIDED_ONLY"' \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v6.0/act_<AD_ACCOUNT_ID>/customaudiences| Parámetro | Descripción |
|---|---|
allowed_domainslist<string> | A list of domains that the audience is restricted to. |
claim_objectiveenum {AUTOMOTIVE_MODEL, COLLABORATIVE_ADS, HOME_LISTING, MEDIA_TITLE, PRODUCT, TRAVEL, VEHICLE, VEHICLE_OFFER} | Specifies the objective of audiences with |
content_typeenum {AUTOMOTIVE_MODEL, DESTINATION, FLIGHT, HOME_LISTING, HOTEL, LOCAL_SERVICE_BUSINESS, LOCATION_BASED_ITEM, MEDIA_TITLE, OFFLINE_PRODUCT, PRODUCT, VEHICLE, VEHICLE_OFFER} | Specifies a mandatory content type for |
customer_file_sourceenum {USER_PROVIDED_ONLY, PARTNER_PROVIDED_ONLY, BOTH_USER_AND_PARTNER_PROVIDED} | Source of customer information in the uploaded file. |
dataset_idnumeric string or integer | The offline conversion dataset associated with this audience. |
descriptionstring | The description for this custom audience |
enable_fetch_or_createboolean | If |
event_source_groupnumeric string or integer | Specifies event source group for |
event_sourcesarray<JSON object> | Specifies event sources for |
is_value_basedboolean | Whether the audience is used to seed a new value based lookalike audience. |
list_of_accountslist<int64> | List of user and page accounts |
lookalike_specJSON-encoded string | The specification for creating a lookalike audience. |
namestring | The name of this custom audience. |
opt_out_linkstring | Your opt-out URL so people can choose not to be targeted. |
origin_audience_idnumeric string or integer | The ID of origin Custom Audience.The origin audience you create must have a minimum size of 100. |
pixel_idnumeric string or integer | The pixel associated with this audience |
prefillboolean | You can specify |
product_set_idnumeric string or integer | The Product Set to target with this audience |
retention_daysint64 | Number of days to keep the user in this cluster. You can use any value between |
rulestring | Audience rule to be applied on the referrer URL. Used for website custom audiences, product audiences, and video remarketing audiences. |
rule_aggregationstring | Aggregation rule |
subtypeenum {CUSTOM, WEBSITE, APP, OFFLINE_CONVERSION, CLAIM, PARTNER, MANAGED, VIDEO, LOOKALIKE, ENGAGEMENT, BAG_OF_ACCOUNTS, STUDY_RULE_AUDIENCE, FOX, MEASUREMENT, REGULATED_CATEGORIES_AUDIENCE} | Type of custom audience, derived from original data source. |
id in the return type.id: numeric string, message: string, | Error | Descripción |
|---|---|
| 2654 | Failed to create custom audience |
| 200 | Permissions error |
| 100 | Invalid parameter |
| 80003 | There have been too many calls to this ad-account. Wait a bit and try again. For more info, please refer to https://developers.facebook.com/docs/graph-api/overview/rate-limiting. |
| 2663 | Terms of service has not been accepted. To accept, go to https://www.facebook.com/customaudiences/app/tos |
| 2633 | This shared login is disabled. Go to Ads Manager for more information. |
| 368 | The action attempted has been deemed abusive or is otherwise disallowed |
| 190 | Invalid OAuth 2.0 Access Token |
| 2664 | The corporate terms of service has not been accepted. To accept, go to https://business.facebook.com/ads/manage/customaudiences/tos.php |
If a person opted out of being targeted, you must remove the person from all custom audiences containing this person. To opt-out a person from audience after they have clicked through to your opt-out URL, make an HTTP DELETE call to:
https://graph.facebook.com/<API_VERSION>/act_<AD_ACCOUNT_ID>/usersofanyaudience
Provide the same fields as you do in a user update.
This will remove the people you specify from ALL custom file custom audiences belonging to the specified ad account.
To update the audience name:
use FacebookAds\Object\CustomAudience;
use FacebookAds\Object\Fields\CustomAudienceFields;
$audience = new CustomAudience(<CUSTOM_AUDIENCE_ID>);
$audience->setData(array(
CustomAudienceFields::NAME => 'Updated Name for CA',
));
$audience->update();
echo $audience->{CustomAudienceFields::NAME}.PHP_EOL;from facebookads.adobjects.customaudience import CustomAudience
audience = CustomAudience('<CUSTOM_AUDIENCE_ID>')
audience[CustomAudience.Field.name] = 'Updated name for CA'
audience.remote_update()new CustomAudience(<CUSTOM_AUDIENCE_ID>, context).update()
.setName("Updated Name for CA")
.execute();curl \
-F 'name=Updated Name for CA' \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v2.11/<CUSTOM_AUDIENCE_ID>To edit an Opt-out link:
use FacebookAds\Object\CustomAudience;
use FacebookAds\Object\Fields\CustomAudienceFields;
$audience = new CustomAudience(<CUSTOM_AUDIENCE_ID>);
$audience->setData(array(
CustomAudienceFields::OPT_OUT_LINK => 'http://www.yourdomain.com/optout',
));
$audience->update();
echo $audience->{CustomAudienceFields::OPT_OUT_LINK}.PHP_EOL;from facebookads.adobjects.customaudience import CustomAudience
audience = CustomAudience('<CUSTOM_AUDIENCE_ID>')
audience[CustomAudience.Field.opt_out_link] = \
'http://www.yourdomain.com/optout'
audience.remote_update()new CustomAudience(<CUSTOM_AUDIENCE_ID>, context).update()
.setOptOutLink("http://www.yourdomain.com/optout")
.execute();curl \
-F 'opt_out_link=http://www.yourdomain.com/optout' \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v2.11/<CUSTOM_AUDIENCE_ID>/{custom_audience_id}.POST /v6.0/<CUSTOM_AUDIENCE_ID>/ HTTP/1.1
Host: graph.facebook.com
name=Updated+Name+for+CA/* PHP SDK v5.0.0 */
/* make the API call */
try {
// Returns a `Facebook\FacebookResponse` object
$response = $fb->post(
'/<CUSTOM_AUDIENCE_ID>/',
array (
'name' => 'Updated Name for CA',
),
'{access-token}'
);
} catch(Facebook\Exceptions\FacebookResponseException $e) {
echo 'Graph returned an error: ' . $e->getMessage();
exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
echo 'Facebook SDK returned an error: ' . $e->getMessage();
exit;
}
$graphNode = $response->getGraphNode();
/* handle the result *//* make the API call */
FB.api(
"/<CUSTOM_AUDIENCE_ID>/",
"POST",
{
"name": "Updated Name for CA"
},
function (response) {
if (response && !response.error) {
/* handle the result */
}
}
);Bundle params = new Bundle();
params.putString("name", "Updated Name for CA");
/* make the API call */
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/<CUSTOM_AUDIENCE_ID>/",
params,
HttpMethod.POST,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
/* handle the result */
}
}
).executeAsync();// For more complex open graph stories, use `FBSDKShareAPI`
// with `FBSDKShareOpenGraphContent`
NSDictionary *params = @{
@"name": @"Updated Name for CA",
};
/* make the API call */
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
initWithGraphPath:@"/<CUSTOM_AUDIENCE_ID>/"
parameters:params
HTTPMethod:@"POST"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
id result,
NSError *error) {
// Handle the result
}];curl -X POST \
-F 'name="Updated Name for CA"' \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v6.0/<CUSTOM_AUDIENCE_ID>/| Parámetro | Descripción |
|---|---|
allowed_domainslist<string> | A list of domains that the audience is restricted to |
claim_objectiveenum {AUTOMOTIVE_MODEL, COLLABORATIVE_ADS, HOME_LISTING, MEDIA_TITLE, PRODUCT, TRAVEL, VEHICLE, VEHICLE_OFFER} | Specifies the objective of audiences with |
content_typeenum {AUTOMOTIVE_MODEL, DESTINATION, FLIGHT, HOME_LISTING, HOTEL, LOCAL_SERVICE_BUSINESS, LOCATION_BASED_ITEM, MEDIA_TITLE, OFFLINE_PRODUCT, PRODUCT, VEHICLE, VEHICLE_OFFER} | Specifies a mandatory content type for |
customer_file_sourceenum {USER_PROVIDED_ONLY, PARTNER_PROVIDED_ONLY, BOTH_USER_AND_PARTNER_PROVIDED} | Source of customer information in the uploaded file |
descriptionstring | The description for this custom audience |
enable_fetch_or_createboolean | Fetch custom audience instead of create new one when there exists custom audience with identical name, claim_objective, content_type, event_source_group/event_sources/sliced_event_source_group, inclusions, exclusions and rule |
event_source_groupnumeric string or integer | Specifies a mandatory content type for |
event_sourcesarray<JSON object> | Specifies a mandatory content type for |
lookalike_specJSON-encoded string | The specification for creating a lookalike audience |
namestring | The name of this custom audience |
opt_out_linkstring | Your opt-out URL so people can choose not to be targeted |
product_set_idnumeric string or integer | The Product Set to target with this audience |
retention_daysint64 | Number of days to keep the user in this cluster. You can use any value between 1 and 180 days. Defaults to forever, if not specified. Only available for Customer File Custom Audience, including Custom Audiences created from CRM data. |
rulestring | Audience rule to be applied on the referrer URL. Used for website custom audiences, product audiences, and video remarketing audiences. |
rule_aggregationstring | Aggregation rule |
success: bool, message: string, | Error | Descripción |
|---|---|
| 100 | Invalid parameter |
| 200 | Permissions error |
| 2650 | Failed to update the custom audience |
| 2651 | Failed to create lookalike custom audience |
| 368 | The action attempted has been deemed abusive or is otherwise disallowed |
When you delete a Custom Audience, it'll be permanently removed from your account and your ads using it will stop running. You won't be able to restart any ads that used this audience in the past.
/{custom_audience_id}.DELETE /v6.0/<CUSTOM_AUDIENCE_ID>/ HTTP/1.1
Host: graph.facebook.com/* PHP SDK v5.0.0 */
/* make the API call */
try {
// Returns a `Facebook\FacebookResponse` object
$response = $fb->delete(
'/<CUSTOM_AUDIENCE_ID>/',
array (),
'{access-token}'
);
} catch(Facebook\Exceptions\FacebookResponseException $e) {
echo 'Graph returned an error: ' . $e->getMessage();
exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
echo 'Facebook SDK returned an error: ' . $e->getMessage();
exit;
}
$graphNode = $response->getGraphNode();
/* handle the result *//* make the API call */
FB.api(
"/<CUSTOM_AUDIENCE_ID>/",
"DELETE",
function (response) {
if (response && !response.error) {
/* handle the result */
}
}
);/* make the API call */
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/<CUSTOM_AUDIENCE_ID>/",
null,
HttpMethod.DELETE,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
/* handle the result */
}
}
).executeAsync();// For more complex open graph stories, use `FBSDKShareAPI`
// with `FBSDKShareOpenGraphContent`
/* make the API call */
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
initWithGraphPath:@"/<CUSTOM_AUDIENCE_ID>/"
parameters:params
HTTPMethod:@"DELETE"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
id result,
NSError *error) {
// Handle the result
}];curl -X DELETE -G \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v6.0/<CUSTOM_AUDIENCE_ID>/success: bool, | Error | Descripción |
|---|---|
| 200 | Permissions error |
| 2656 | Failed to delete custom audience because associated lookalikes exist |
| 100 | Invalid parameter |
| 368 | The action attempted has been deemed abusive or is otherwise disallowed |
| 2651 | Failed to create lookalike custom audience |
| 190 | Invalid OAuth 2.0 Access Token |
| 80003 | There have been too many calls to this ad-account. Wait a bit and try again. For more info, please refer to https://developers.facebook.com/docs/graph-api/overview/rate-limiting. |