Basic targeting includes:
Advertisers running housing, employment, credit ads, issues, election, or political ads who are based in the United States or running ads targeted to the United States have different sets of restrictions.
Get basic demographic and location-based targeting data to define targeting from Targeting Search, then specify options in the targeting spec, which contains ad set attributes defining who should see the ad.
Note: You must specify at least one country in targeting, unless you use a Custom Audience.
curl -X POST \
-F 'name=My AdSet' \
-F 'optimization_goal=REACH' \
-F 'billing_event=IMPRESSIONS' \
-F 'bid_amount=2' \
-F 'daily_budget=1000' \
-F 'campaign_id=<CAMPAIGN_ID>' \
-F 'targeting={
"geo_locations": {"countries":["US"]},
"industries": [{"id":6009003307783,"name":"Accounting and finance"}],
"life_events": [{"id":6003054185372,"name":"Recently Moved"}],
"relationship_statuses": [2,4]
}' \
-F 'status=ACTIVE' \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v24.0/act_<AD_ACCOUNT_ID>/adsets
| Name | Description |
|---|---|
array | Genders to target. Defaults to all. |
int | Minimum age. Defaults to 18. If used, must be 13 or higher. If the app has custom settings for age restrictions, the app's age restrictions will be used for ads with APP_INSTALL goals. For example, if you set |
int | Maximum age. If used, must be 65 or lower. |
Search and retrieve values for location targeting with Targeting Search. This targeting has two parameters: geo_locations to target locations, and optionally, excluded_geo_locations to exclude areas.
Use country_groups for geo_locations to target broader geographic regions such as Europe or North America.
Using radius can cause an error, code: 100, subcode 1815946, when targeting multiple locations. We recommend creating an ad for each location or not using radius in your call.
| Name | Description |
|---|---|
array | Country targeting. Requires array of country codes, see Targeting Search, Countries. |
array | State, province, or region. Available values, see Targeting Search, Regions. Limit: 200. |
array | Specify |
array | Target Zip Code, See targeting search API. Limit: 50,000 (formerly 2,500). If you provide more than 2,500, we create an array known as To read a |
array | Provide a specific place. Limit: 200. |
array | Available for all objectives. Provide exact location in latitude and longitude or address as the center of an area. Also specify radius for your location from .63 to 50 miles, or 1 to 80 kilometers. |
float | Latitude of location |
float | Longitude of location |
string | Name for address. You can use with |
float | Radius around latitude/longitude, in miles unless otherwise in |
string | Optional.
|
string | Address at latitude/longitude, such as 1601 Willow Rd, Menlo Park, CA. Suggested format: street number street name, city, state/province, country. Exclude postal codes. |
array | Geomarkets using DMA and/or Comscore Markets. Limit: 2500. |
array | Key for electoral districts. Get districts at Targeting Search, Electoral. |
array | The array
|
array | Global geographical regions and free trade areas. See Targeting Search, Country Groups. Provide array of country group codes:
Example: |
curl -X POST \
-F 'name="My Reach Ad Set"' \
-F 'optimization_goal="REACH"' \
-F 'billing_event="IMPRESSIONS"' \
-F 'bid_amount=2' \
-F 'daily_budget=1000' \
-F 'campaign_id="<AD_CAMPAIGN_ID>"' \
-F 'targeting={
"geo_locations": {
"countries": [
"US"
]
},
"facebook_positions": [
"feed"
]
}' \
-F 'status="PAUSED"' \
-F 'promoted_object={
"page_id": "<PAGE_ID>"
}' \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v24.0/act_<AD_ACCOUNT_ID>/adsets
curl -X POST \
-F 'name="My Reach Ad Set"' \
-F 'optimization_goal="REACH"' \
-F 'billing_event="IMPRESSIONS"' \
-F 'bid_amount=2' \
-F 'daily_budget=1000' \
-F 'campaign_id="<AD_CAMPAIGN_ID>"' \
-F 'targeting={
"excluded_geo_locations": {
"regions": [
{
"key": "3847"
}
]
},
"geo_locations": {
"countries": [
"US"
]
},
"facebook_positions": [
"feed"
]
}' \
-F 'status="PAUSED"' \
-F 'promoted_object={
"page_id": "<PAGE_ID>"
}' \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v24.0/act_<AD_ACCOUNT_ID>/adsets
curl -X POST \
-F 'name=My AdSet' \
-F 'optimization_goal=REACH' \
-F 'billing_event=IMPRESSIONS' \
-F 'bid_amount=2' \
-F 'daily_budget=1000' \
-F 'campaign_id=<CAMPAIGN_ID>' \
-F 'targeting={
"geo_locations":{
"zips":[{"key":"US:94304"},{"key":"US:00501"}]}
}' \
-F 'status=ACTIVE' \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v24.0/act_<AD_ACCOUNT_ID>/adsets
The following code sets up targeting for:
curl -X POST \
-F 'name=My AdSet' \
-F 'optimization_goal=REACH' \
-F 'billing_event=IMPRESSIONS' \
-F 'bid_amount=2' \
-F 'daily_budget=1000' \
-F 'campaign_id=<CAMPAIGN_ID>' \
-F 'targeting={
"geo_locations": {
"custom_locations": [
{"address_string":"1601 Willow Road, Menlo Park, CA","radius":"5"},
{
"latitude": "36",
"longitude": "-121.0",
"radius": "5",
"distance_unit": "kilometer"
}
],
"geo_markets": [
{"key":"DMA:501","name":"New York"},
{"key":"DMA:543","name":"Springfield-Holyoke"},
{"key":"COMSCORE_MARKET:2001","name":"New York, NY"},
{"key":"COMSCORE_MARKET:2051","name":"New Orleans, LA"}
],
"location_types": ["recent","home"]
}
}' \
-F 'status=ACTIVE' \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v24.0/act_<AD_ACCOUNT_ID>/adsets
To target males age 20-24 within 10 miles of Menlo Park, CA or living in Texas or in Japan:
First, get Japan's country code:
curl -G \
-d 'location_types=["country"]' \
-d 'type=adgeolocation' \
-d 'q=japan' \
-d 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v24.0/search
Get Texas's region code:
curl -G \
-d 'location_types=["region"]' \
-d 'type=adgeolocation' \
-d 'q=texas' \
-d 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v24.0/search
Search Menlo Park, CA city code:
curl -G \
-d 'location_types=["city"]' \
-d 'type=adgeolocation' \
-d 'q=menlo' \
-d 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v24.0/search
Provide genders and age as age_min and age_max.
Our targeting spec is ready with country, region and city codes:
curl \
-F 'name=My First AdSet' \
-F 'daily_budget=10000' \
-F 'bid_amount=300' \
-F 'billing_event=IMPRESSIONS' \
-F 'optimization_goal=REACH' \
-F 'campaign_id=<CAMPAIGN_ID>' \
-F 'promoted_object={"page_id":"<PAGE_ID>"}' \
-F 'targeting={
"age_max": 24,
"age_min": 20,
"device_platforms": ["mobile"],
"genders": [1],
"geo_locations": {
"countries": ["JP"],
"regions": [{"key":"3886"}],
"cities": [
{
"key": "2420605",
"radius": 10,
"distance_unit": "mile"
}
]
},
"publisher_platforms": ["facebook","audience_network"]
}' \
-F 'status=PAUSED' \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v24.0/act_<AD_ACCOUNT_ID>/adsets
Set custom_type to multi_city and define either country or country_group as described before.
curl \
-F 'name=My AdSet' \
-F 'optimization_goal=REACH' \
-F 'billing_event=IMPRESSIONS' \
-F 'bid_amount=2' \
-F 'daily_budget=1000' \
-F 'campaign_id=<CAMPAIGN_ID>' \
-F 'targeting={
"geo_locations": {
"custom_locations": [
{
"custom_type": "multi_city",
"min_population": 500000,
"max_population": 1000000,
"country": "BR"
},
{"custom_type":"multi_city","country_group":"Europe"}
],
"location_types": ["recent","home"]
}
}' \
-F 'status=ACTIVE' \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v24.0/act_<AD_ACCOUNT_ID>/adsets
| Name | Description |
|---|---|
int | The minimum population threshold on which the cities are chosen for targeting. |
int | The maximum population threshold on which the cities are chosen for targeting. |
Target based on interests from someone's timeline, from Pages liked or from keywords associated with Pages or apps someone uses. See Targeting Search, Interests.
To target people interested in soccer, first query:
curl -G \
-d 'type=adinterest' \
-d 'q=soccer' \
-d 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v24.0/search
Add this interest by name and id to a targeting spec, where path is the path of this interest in ads tools.
curl -X POST \
-F 'name="My First AdSet"' \
-F 'daily_budget=10000' \
-F 'bid_amount=300' \
-F 'billing_event="IMPRESSIONS"' \
-F 'optimization_goal="REACH"' \
-F 'campaign_id="<CAMPAIGN_ID>"' \
-F 'promoted_object={
"page_id": "<PAGE_ID>"
}' \
-F 'targeting={
"facebook_positions": [
"feed"
],
"geo_locations": {
"countries": [
"US"
],
"regions": [
{
"key": "4081"
}
],
"cities": [
{
"key": 777934,
"radius": 10,
"distance_unit": "mile"
}
]
},
"genders": [
1
],
"age_max": 24,
"age_min": 20,
"publisher_platforms": [
"facebook",
"audience_network"
],
"device_platforms": [
"mobile"
],
"flexible_spec": [
{
"interests": [
{
"id": "<INTEREST_ID>",
"name": "<INTEREST_NAME>"
}
]
}
]
}' \
-F 'status="PAUSED"' \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v24.0/act_<AD_ACCOUNT_ID>/adsets
Here's another example:
curl \
-F 'name=My AdSet' \
-F 'optimization_goal=REACH' \
-F 'billing_event=IMPRESSIONS' \
-F 'bid_amount=2' \
-F 'daily_budget=1000' \
-F 'campaign_id=<CAMPAIGN_ID>' \
-F 'targeting={
"geo_locations": {"countries":["US"]},
"interests": [
{"id":6003139266461,"name":"Movies"},
{"id":6003397425735,"name":"Tennis"},
{"id":6003659420716,"name":"Cooking"}
]
}' \
-F 'status=ACTIVE' \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v24.0/act_<AD_ACCOUNT_ID>/adsets
| Name | Description |
|---|---|
array | Array with |
Target based on digital activities, devices people use, past or intended purchases, and travel. View options at Browse such as Frequent Travelers. See Targeting Search API.
curl -G \
-d 'type=adTargetingCategory' \
-d 'class=behaviors' \
-d 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v24.0/search
Add the behavior to targeting spec:
curl \
-F 'name=My First AdSet' \
-F 'daily_budget=10000' \
-F 'bid_amount=300' \
-F 'billing_event=IMPRESSIONS' \
-F 'optimization_goal=REACH' \
-F 'campaign_id=<CAMPAIGN_ID>' \
-F 'promoted_object={"page_id":"<PAGE_ID>"}' \
-F 'targeting={
"age_max": 24,
"age_min": 20,
"behaviors": [{"id":6002714895372,"name":"All frequent travelers"}],
"device_platforms": ["mobile"],
"genders": [1],
"geo_locations": {
"countries": ["JP"],
"regions": [{"key":"3886"}],
"cities": [
{
"key": "2420605",
"radius": 10,
"distance_unit": "mile"
}
]
},
"interests": [{"id":6003107902433,"name":"Association football (Soccer)"}],
"publisher_platforms": ["facebook","audience_network"]
}' \
-F 'status=PAUSED' \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v24.0/act_<AD_ACCOUNT_ID>/adsets
Another example:
curl -X POST \
-F 'name="My AdSet"' \
-F 'optimization_goal="REACH"' \
-F 'billing_event="IMPRESSIONS"' \
-F 'bid_amount=2' \
-F 'daily_budget=1000' \
-F 'campaign_id="<CAMPAIGN_ID>"' \
-F 'targeting={
"facebook_positions": [
"feed"
],
"geo_locations": {
"countries": [
"US"
]
},
"behaviors": [
{
"id": 6007101597783,
"name": "Business Travelers"
},
{
"id": 6004386044572,
"name": "Android Owners (All)"
}
]
}' \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v24.0/act_<AD_ACCOUNT_ID>/adsets
| Name | Description |
|---|---|
array | Array with |
Other targeting: