使用 AND
和 OR
陳述式合併或排除不同的目標設定選項,即可觸及 flexible_spec
中的特定用戶組合。Facebook 透過 AND
以及規格以外的所有族群(例如年齡、性別、地理位置)評估 flexible_spec
中的目標設定。我們也使用 AND
評估 flexible_spec
中的每個頂級陣列元素;使用 OR
評估次級陣列元素。
目標設定族群(例如在 flexible_spec
內指定的行為)不可在 flexible_spec
之外使用。
指定 flexible_spec
和 exclusions
,如下所示:
欄位 | 說明 |
---|---|
類型:JSON 物件 | 陣列的陣列。每個都包含適當格式的目標設定族群,例如興趣、行為和人口統計資料。頂級陣列的限制為 25 個,次級陣列的限制為 1,000 個。 |
類型:JSON 物件 | 包含適當格式的目標設定族群,例如興趣、行為和人口統計資料(「教育」、「生活事件」、「工作」)。 |
彈性目標設定中可使用這些欄位:
connections
friends_of_connections
custom_audiences
interests
behaviors
college_years
education_majors
education_schools
education_statuses
family_statuses
home_value
interested_in
income
industries
life_events
user_adclusters
work_positions
work_employers
要鎖定居住在美國、年齡在 18-43 歲之間、最近沒有搬家且是旅行者或喜歡足球或電影且為新婚或喜歡音樂的用戶:
use FacebookAds\Object\AdSet;
use FacebookAds\Object\Fields\AdSetFields;
use FacebookAds\Object\Values\AdSetBillingEventValues;
use FacebookAds\Object\Values\AdSetOptimizationGoalValues;
use FacebookAds\Object\Fields\TargetingFields;
use FacebookAds\Object\Targeting;
$adset = new AdSet(null, 'act_<AD_ACCOUNT_ID>');
$adset->setData(array(
AdSetFields::NAME => 'My AdSet',
AdSetFields::OPTIMIZATION_GOAL => AdSetOptimizationGoalValues::REACH,
AdSetFields::BILLING_EVENT => AdSetBillingEventValues::IMPRESSIONS,
AdSetFields::BID_AMOUNT => 150,
AdSetFields::DAILY_BUDGET => 2000,
AdSetFields::CAMPAIGN_ID => <CAMPAIGN_ID>,
AdSetFields::TARGETING => (new Targeting())->setData(array(
TargetingFields::GEO_LOCATIONS => array(
'countries' => array(
'US',
),
),
TargetingFields::AGE_MIN => 18,
TargetingFields::AGE_MAX => 43,
TargetingFields::FLEXIBLE_SPEC => array(
array(
TargetingFields::BEHAVIORS => array(
array(
'id' => 6002714895372,
'name' => 'All travelers',
),
),
TargetingFields::INTERESTS => array(
array(
'id' => 6003107902433,
'name' => 'Association football (Soccer)',
),
array(
'id' => 6003139266461,
'name' => 'Movies',
),
),
),
array(
TargetingFields::INTERESTS => array(
array(
'id' => 6003020834693,
'name' => 'Music',
),
),
TargetingFields::LIFE_EVENTS => array(
array(
'id' => 6002714398172,
'name' => 'Newlywed (1 year)',
),
),
),
),
TargetingFields::EXCLUSIONS => array(
TargetingFields::RELATIONSHIP_STATUSES => array(1, 3),
TargetingFields::LIFE_EVENTS => array(
array(
'id' => 6003054185372,
'name' => 'Recently moved',
),
),
),
)),
));
$adset->create(array(
AdSet::STATUS_PARAM_NAME => AdSet::STATUS_ACTIVE,
));
from facebookads.adobjects.adset import AdSet
adset = AdSet(parent_id='act_<AD_ACCOUNT_ID>')
adset.update({
AdSet.Field.name: 'My AdSet',
AdSet.Field.optimization_goal: AdSet.OptimizationGoal.reach,
AdSet.Field.billing_event: AdSet.BillingEvent.impressions,
AdSet.Field.bid_amount: 150,
AdSet.Field.daily_budget: 2000,
AdSet.Field.campaign_id: <CAMPAIGN_ID>,
AdSet.Field.targeting: {
'geo_locations': {
'countries': ['US'],
},
'age_min': 18,
'age_max': 43,
'flexible_spec': [
{
'behaviors': [
{
'id': 6002714895372,
'name': 'All 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)',
},
],
},
],
'exclusions': {
'relationship_statuses': [1, 3],
'life_events': [
{
'id': 6003054185372,
'name': 'Recently moved',
},
],
},
},
})
adset.remote_create(params={
'status': AdSet.Status.active,
})
AdSet adSet = new AdAccount(act_<AD_ACCOUNT_ID>, context).createAdSet()
.setName("My AdSet")
.setOptimizationGoal(AdSet.EnumOptimizationGoal.VALUE_REACH)
.setBillingEvent(AdSet.EnumBillingEvent.VALUE_IMPRESSIONS)
.setBidAmount(150L)
.setDailyBudget(2000L)
.setCampaignId(<CAMPAIGN_ID>)
.setTargeting(
new Targeting()
.setFieldAgeMax(43L)
.setFieldAgeMin(18L)
.setFieldExclusions(
new FlexibleTargeting()
.setFieldLifeEvents(Arrays.asList(
new IDName()
.setFieldId("6003054185372")
.setFieldName("Recently moved")
))
.setFieldRelationshipStatuses(Arrays.asList(1L, 3L))
)
.setFieldFlexibleSpec(Arrays.asList(
new FlexibleTargeting()
.setFieldBehaviors(Arrays.asList(
new IDName()
.setFieldId("6002714895372")
.setFieldName("All travelers")
))
.setFieldInterests(Arrays.asList(
new IDName()
.setFieldId("6003107902433")
.setFieldName("Association football (Soccer)")
,
new IDName()
.setFieldId("6003139266461")
.setFieldName("Movies")
))
,
new FlexibleTargeting()
.setFieldInterests(Arrays.asList(
new IDName()
.setFieldId("6003020834693")
.setFieldName("Music")
))
.setFieldLifeEvents(Arrays.asList(
new IDName()
.setFieldId("6002714398172")
.setFieldName("Newlywed (1 year)")
))
))
.setFieldGeoLocations(
new TargetingGeoLocation()
.setFieldCountries(Arrays.asList("US"))
)
)
.setStatus(AdSet.EnumStatus.VALUE_ACTIVE)
.execute();
String ad_set_id = adSet.getId();
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":"All 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
有了彈性規格,產生的廣告受眾將是:
(族群 1 or
族群 2 or
族群 3)和(族群 4 or
族群 5)和 族群 6
flexible_spec= [ { 'segment_type':[segment1, segment2], 'segment_type':[segment3] }, { 'segment_type':[segment4, segment5] }, { 'segment_type':[segment6] } ]
例如,建立居住在美國、年齡在 20-24 歲之間、最近沒有搬家且是旅行者或喜歡足球或電影且為新婚或喜歡音樂的廣告受眾:
targeting= {'geo_locations':{ 'countries': ['US'], }, 'age_min':20, 'age_max':24, 'flexible_spec': [ { 'behaviors':[{'id':6002714895372,'name':'All 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'},], }, }
此廣告組合的目標設定規格:
{ "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": "All travelers" } ] }, { "interests": [ { "id": "6003020834693", "name": "Music" } ], "life_events": [ { "id": "6002714398172", "name": "Newlywed (1 year)" } ] } ], "geo_locations": { "countries": [ "US" ] } }, "id": "6015417075447" }