Combine or exclude different targeting options to reach a specific set of users in the flexible_spec
with AND
and OR
statements. Facebook evaluates targeting in flexible_spec
via AND
with all segments outside the spec such as age, gender, geo locations. We also evaluate each top level array element in flexible_spec
with AND
; we evaluate second-level array elements with OR
.
Targeting segments, such as behaviors specified inside flexible_spec
, are not available for use outside of flexible_spec
.
Specify flexible_spec
and exclusions
as follows:
Field | Description |
---|---|
type: JSON Object | Array of arrays. Each contains a targeting segment in appropriate format, such as interests, behaviors, and demographics. The top level array has a limit of 25 and secondary level array has a limit of 1,000. |
type: JSON Object | Contains a targeting segment in its appropriate format, such as interests, behaviors, and demographics ("education", "life events", "work"). |
Use these fields in flexible targeting:
custom_audiences
interests
behaviors
college_years
education_majors
education_schools
education_statuses
family_statuses
income
industries
life_events
user_adclusters
work_positions
work_employers
To target people who live in the U.S, aged between 18-43, who have not recently moved and are travelers or like soccer or movies and are newlyweds or like music:
curl \ -F 'name=My AdSet' \ -F 'optimization_goal=REACH' \ -F 'billing_event=IMPRESSIONS' \ -F 'bid_amount=150' \ -F 'daily_budget=2000' \ -F 'campaign_id=<CAMPAIGN_ID>' \ -F 'targeting={ "age_max": 43, "age_min": 18, "exclusions": { "relationship_statuses": [1,3], "life_events": [{"id":6003054185372,"name":"Recently moved"}] }, "flexible_spec": [ { "behaviors": [{"id":6002714895372,"name":"Frequent Travelers"}], "interests": [ {"id":6003107902433,"name":"Association football (Soccer)"}, {"id":6003139266461,"name":"Movies"} ] }, { "interests": [{"id":6003020834693,"name":"Music"}], "life_events": [{"id":6002714398172,"name":"Newlywed (1 year)"}] } ], "geo_locations": {"countries":["US"]} }' \ -F 'status=ACTIVE' \ -F 'access_token=<ACCESS_TOKEN>' \ https://graph.facebook.com/v2.11/act_<AD_ACCOUNT_ID>/adsets
With this flexible spec, the resulting audience is:
(segment 1 or
segment2 or
segment3) and (segment 4 or
segment 5) and segment 6
flexible_spec= [ { 'segment_type':[segment1, segment2], 'segment_type':[segment3] }, { 'segment_type':[segment4, segment5] }, { 'segment_type':[segment6] } ]
For example, create an audience who lives in the U.S, aged 20-24, who have not recently moved and are travelers or like soccer or movies and are newlyweds or like music:
targeting= {'geo_locations':{ 'countries': ['US'], }, 'age_min':20, 'age_max':24, 'flexible_spec': [ { 'behaviors':[{'id':6002714895372,'name':'Frequent Travelers'},], 'interests':[ {'id':6003107902433,'name':'Association football (Soccer)'}, {'id':6003139266461, 'name': 'Movies'},], }, { 'life_events':[{'id': 6002714398172, 'name': 'Newlywed (1 year)'}], 'interests':[{'id':6003020834693,'name':'Music'},], }, ], 'exclusions': { 'life_events':[{'id':6003054185372,'name':'Recently moved'},], }, }
The targeting spec for this ad set:
{ "targeting": { "age_min": 20, "age_max": 24, "exclusions": { "life_events": [ { "id": "6003054185372", "name": "Recently moved" } ], }, "flexible_spec": [ { "interests": [ { "id": "6003107902433", "name": "Association football (Soccer)" }, { "id": "6003139266461", "name": "Movies" } ], "behaviors": [ { "id": "6002714895372", "name": "Frequent Travelers" } ] }, { "interests": [ { "id": "6003020834693", "name": "Music" } ], "life_events": [ { "id": "6002714398172", "name": "Newlywed (1 year)" } ] } ], "geo_locations": { "countries": [ "US" ] } }, "id": "6015417075447" }