Graph API Version

Graph API Targeting Options

You can target general demographic groups with pieces of content (e.g., a post to your page) published via the Graph API. In this section, we show you how to specify targeting options.

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 (using the targeting field), or to suggest who might want to see a post (using the feed_targeting field). Both targeting and feed_targeting began using the geo_location object in Graph API version 2.8. Previous versions of the Graph API used different methods. Developers who want to use these options with pages should upgrade to use version 2.8 or greater, because the underlying functionality was vastly improved.

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

"targeting": {
  "geo_locations": {
    "countries": [
      "CA"
    ],
    "cities": [
      {
        "key": "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 adgeolocation, and use the returned key. For example:

/search/?type=adgeolocation&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 adgeolocation, 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.10/search?type={filter-type}&q={keyword-to-search} 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, adeducationschool, adeducationmajor, adlocale, adworkemployer, adkeyword, adzipcode, adgeolocation, audienceinterest}


adcity and adregion have been replaced by adgeolocation.

Fields

Full response data is a list of search results. The structure of each result varies by the type used to query (this structure can be seen in the Ads Autocomplete reference), but there are two important fields returned, which are what your app needs 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