Graph API Version

Graph API Targeting Options

Certain pieces of content published via the Graph API can be targeted to general demographic groups. Below we show you how to retrieve some of the valid options which are available for targeting.

geo_location field

geo_location is a sub-object used on a couple of fields on the /page/feed edge. It can be used to either limit who can see a post (the targeting field) or suggest who might want to see a post (the feed_targeting field.)

Starting in Graph API version 2.8, both of the targeting fields use the geo_location object. Previous versions of the API used different methods. Developers who want to use these options with pages should upgrade to use version 2.8 since the underlying functionality is vastly improved.

The geo_location sub-object returns location data. Here's an example as part of a result of a query of the /page/feed edge with targeting data set:

"targeting": {
  "geo_locations": {
    "countries": [
      "CA"
    ],
    "cities": [
      {
        "id": "296875",
        "name": "Toronto"
      }
    ]
  }
},

And feed_targeting:

"feed_targeting": {
  "geo_locations": {
    "countries": [
      "FR"
    ],
    "regions": [
      {
        "key": "3847"
      }
    ],
    "cities": [
      {
        "key": "2505639"
      }
    ]
  }
},

And an example that includes zips:

"targeting": {
  "geo_locations": {
    "countries": [
      "FR"
    ],
    "regions": [
      {
        "key": "3847"
      }
    ],
    "cities": [
      {
        "key": "2505639"
      }
    ],
    "zips": [
      {
        "key": "US:98121"
      }
    ]
  }
},
ArgumentSource

countries

An array of 2-digit ISO 3166 format codes.

regions

An array of up to 200 regions. Use the method described in the section below with the type adregion and use the returned key. For example:

/search/?type=adregion&q=California

returns:

...
  "data": [
    {
      "key": 6,
      "name": "California",
      "country_code": "US"
    }
  ],
...

cities

An array of up to 250 cities. Use the method described in the section below with the type adcity and use the returned key.

zips

An array of up to 2500 zip codes. Zip code searches are covered in our Marketing API documentation and behave the same when used with targeting options for Page feed. The zip field does not work with feed_targeting.

Finding Options

GET /v2.1/search?type=%7Bfilter-type%7D&q=%7Bkeyword-to-search%7D HTTP/1.1
Host: graph.facebook.com

Permissions

  • Any valid access token is required.

Modifiers

Name Description Type

q

The partial or full string of the targeting option you want to find. This field is required.

string

type

The type of targeting option to retrieve.

enum{adcountry, adregion, adcity, adeducationschool, adeducationmajor, adlocale, adworkemployer, adkeyword, adzipcode, adgeolocation, audienceinterest}

Fields

Full response data will be a list of search results. The structure of each result will vary by the type used to query (this structure can be seen in the Ads Autocomplete reference), but there are two important fields returned that are what your app will need to target content:

Name Description Type

name

The full string of a matching result.

string

key

If included, this should be used to define the targeting of published content.

string|int