Basic Targeting

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.

Demographics and Events

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.

Targeting by demographic

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

Fields

NameDescription

genders

array

Genders to target. Defaults to all. 1 targets males, 2 targets females.

age_min

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 age_min to 13 but your app's age minimum is set to 18, 18 will be used in ads targeting.

age_max

int

Maximum age. If used, must be 65 or lower.

Location

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.

Fields

NameDescription

countries

array

Country targeting. Requires array of country codes, see Targeting Search, Countries.
Example: 'countries': ['US']

regions

array

State, province, or region. Available values, see Targeting Search, Regions. Limit: 200.
Example: 'regions': [{'key':'3847'}]

cities

array

Specify key, radius & distance_unit. For key, see Targeting Search, Cities. radius is a distance around cities, from 10 to 50 miles or 17 to 80 kilometers. distance_unit is mile or kilometer. Limit: 250.
Example: 'cities': [{'key':'2430536', 'radius':12, 'distance_unit':'mile'}]

zips

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 location_cluster which represents a set of zip codes.
Example: 'zips':[{'key':'US:94304'},{'key':'US:00501'}]

To read a location_cluster and see the locations targeted: GET /location_cluster_ID

places

array

Provide a specific place. Limit: 200.
Example: "places":[{"key":129672430416115,"name":"SFO", "radius":10, "distance_unit":"mile"}]

custom_locations

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. distance_unit is miles or kilometers; default is mile. Limit: 200. PO Box alone is not supported in address_string. You must provide at minimum, a street address.
Example: 'custom_locations':[{'address_string': '1601 Willow Road, Menlo Park, CA', 'radius': 5},{'latitude': 36, 'longitude': -121.0, 'radius': 5, 'distance_unit': 'kilometer'},]

custom_locations.latitude

float

Latitude of location

custom_locations.longitude

float

Longitude of location

custom_locations.name

string

Name for address. You can use with latitude and longitude values for geo location targeting without providing address_string

custom_locations.radius

float

Radius around latitude/longitude, in miles unless otherwise in distance_unit. From 0.63 to 50 miles, or 1 to 80 kilometers.

custom_locations.distance_unit

string

Optional.

kilometer or mile; default mile

custom_locations.address_string

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.

geo_markets

array

Geomarkets using DMA and/or Comscore Markets. Limit: 2500.
Example: 'geo_markets':[{'key': 'DMA:501', 'name': 'New York'},{'key': COMSCORE_MARKET:2001', 'name': 'New York, NY'}, {'key': 'DMA:543', 'name': 'Springfield-Holyoke'},]

electoral_district

array

Key for electoral districts. Get districts at Targeting Search, Electoral.
Example: 'electoral_districts':[{'key':'US:AK00'},{'key':'US:CA01'},{'key':'US:NY14'}]

location_types

array

The array ['home', 'recent'] is the only option available. If no location_types array is provided, it will default to ['home', 'recent'].

  • recent: People whose recent location is in a selected area, as determined from mobile device data. Not available to exclude locations.
  • home: People whose stated location in their Facebook profile “current city” is in an area. Facebook validates this by IP and information from their friends' profile locations.

country_groups

array

Global geographical regions and free trade areas. See Targeting Search, Country Groups.

Provide array of country group codes:

  • worldwide: Worldwide.
  • africa: Africa.
  • afta: ASEAN Free Trade Area.
  • android_app_store: paid apps supporting countries in Android app store.
  • android_free_store: free apps supporting countries in Android app store.
  • apec: Asia-Pacific Economic Cooperation.
  • asia: Asia
  • caribbean: Caribbean.
  • central_america: Central America.
  • cisfta: Commonwealth of Independent States Free Trade Area.
  • eea: European Economic Area.
  • emerging_markets: countries in Emerging Markets
  • europe: Europe.
  • gcc: Gulf Cooperation Council.
  • itunes_app_store: supported countries for iTunes app store.
  • mercosur: MERCOSUR.
  • nafta: North American Free Trade Agreement.
  • north_america: North America.
  • oceania: Oceania.
  • south_america: South America.

Example: 'country_groups': ['asia','mercosur']

Examples

Target by countries

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

Location targeting with exclusions

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

Target by zip codes

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

Target by custom locations, geomarkets, and location types

The following code sets up targeting for:

  • 5 miles around 1601 Willow Road, Menlo Park, CA
  • 5 kilometers around latitude: 36, longitude: -121.0
  • DMAs 501 and 543 and COMSCORE_MARKETS 2001 and 2054
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

Search and targeting

To target males age 20-24 within 10 miles of Menlo Park, CA or living in Texas or in Japan:

Step 1

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
Step 2

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
Step 3

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
Step 4

Provide genders and age as age_min and age_max.

Step 5

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

Target Multiple Cities

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
Parameters
Name Description

min_population

int

The minimum population threshold on which the cities are chosen for targeting.

max_population

int

The maximum population threshold on which the cities are chosen for targeting.

Interest 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

Fields

Name Description

interests

array

Array with id and optional name fields:
'interests':[{id: 6003139266461, 'name': 'Movies'}, {id: 6003139266462}, 6003139266463]

Behavioral Targeting

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

Fields

Name Description

behaviors

array

Array with id and optional name fields:
'behaviors':[{id: 6004386044572, 'name': 'Android Owners (All)'}, {id: 6004386044573}, 6004386044574]

Learn More

Other targeting:

  • Audience Network - Run ads on Audience Network and extend the reach of your link or app ads