您可由以基本人口統計資料及地點為基礎的目標設定開始。您通常可以從目標設定搜尋取得定義目標設定的資料,然後在目標設定規格中指定選項。目標設定規格為廣告組合屬性,用於定義哪些用戶可看見廣告。
您必須在目標設定中指定至少一個國家/地區,除非是使用自訂廣告受眾。
根據人口統計資料進行目標設定:
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 => 2,
AdSetFields::DAILY_BUDGET => 1000,
AdSetFields::CAMPAIGN_ID => <CAMPAIGN_ID>,
AdSetFields::TARGETING => (new Targeting())->setData(array(
TargetingFields::GEO_LOCATIONS => array(
'countries' => array(
'US',
),
),
TargetingFields::RELATIONSHIP_STATUSES => array(2, 4),
TargetingFields::LIFE_EVENTS => array(
array(
'id' => 6003054185372,
'name' => 'Recently Moved',
),
),
TargetingFields::INDUSTRIES => array(
array(
'id' => 6009003307783,
'name' => 'Accounting and finance',
),
),
)),
));
$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'],
},
'relationship_statuses': [2, 4],
'life_events': [
{
'id': 6003054185372,
'name': 'Recently Moved',
},
],
'industries': [
{
'id': 6009003307783,
'name': 'Accounting and finance',
},
],
},
})
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(2L)
.setDailyBudget(1000L)
.setCampaignId(<CAMPAIGN_ID>)
.setTargeting(
new Targeting()
.setFieldGeoLocations(
new TargetingGeoLocation()
.setFieldCountries(Arrays.asList("US"))
)
.setFieldIndustries(Arrays.asList(
new IDName()
.setFieldId("6009003307783")
.setFieldName("Accounting and finance")
))
.setFieldLifeEvents(Arrays.asList(
new IDName()
.setFieldId("6003054185372")
.setFieldName("Recently Moved")
))
.setFieldRelationshipStatuses(Arrays.asList(2L, 4L))
)
.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=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/v2.11/act_<AD_ACCOUNT_ID>/adsets
名稱 | 說明 |
---|---|
| 要設定為目標的性別。預設為全部。 |
| 年齡下限。預設為 18。若使用,則數值必須為 13 或以上。若應用程式已自訂年齡限制,系統便會將應用程式的年齡限制用於目標為 APP_INSTALL 的廣告。舉例來說,如果您將 |
| 年齡上限。若使用,則數值必須為 65 或以下。 |
在目標設定搜尋 API 搜尋及擷取地點目標設定的值。此目標設定有兩個參數:geo_locations
,用於設定地點目標,以及選用的 excluded_geo_locations
,用於排除區域。
請將 country_groups
用於 geo_locations
以設定歐洲或北美等更廣泛地理區域目標。
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.
名稱 | 說明 |
---|---|
| 國家/地區目標設定。需國碼/區碼陣列。目標設定搜尋:國家/地區。範例: |
| 州、省或地區。可用的值,請參閱目標設定搜尋:地區。上限:200。 |
| 指定 |
| 鎖定的郵遞區號,請參閱目標設定搜尋 API。上限:50,000。先前為 2,500 個。如果您提供的數量超過 2,500,我們將建立一個稱為 若要讀取 |
| 提供特定的地點。上限:200。範例: |
| 適用於所有目標。提供具體地點的經緯度或地址,以作地區的中心。亦需指定地點的半徑,範圍從 0.63 至 50 英里或 1 至 80 公里。 |
| 地點的緯度 |
| 地點的經度 |
| 地址名稱。地理位置目標設定可連同 |
| 緯度/經度的半徑,單位為英里,除非在 |
| 選用。
|
| 指定緯度/經度上的地址,例如 1601 Willow Rd, Menlo Park, CA。建議格式:街道號碼, 街道名稱, 城市, 州/省份, 國家/地區。郵遞區號除外。 |
| 市場索引鍵,格式為「DMA:501」。我們支援所有指定的市場區域(DMA)。在依 DMA 名稱的目標設定搜尋查詢中取得 DMA 代碼。上限:2500 |
| 選區索引鍵。於目標設定搜尋:選區取得選區。 |
| 注意:從第 18.0 版開始, 針對 18.0 以上版本,若未提供
|
| 全球地理區域及自由貿易區。提供國家/地區群組代碼陣列:
請參閱目標設定搜尋:國家/地區群組。 範例: |
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/v21.0/act_<AD_ACCOUNT_ID>/adsets
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/v21.0/act_<AD_ACCOUNT_ID>/adsets
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 => 2,
AdSetFields::DAILY_BUDGET => 1000,
AdSetFields::CAMPAIGN_ID => <CAMPAIGN_ID>,
AdSetFields::TARGETING => (new Targeting())->setData(array(
TargetingFields::GEO_LOCATIONS => array(
TargetingFields::ZIPS => array(
array(
'key' => 'US:94304',
),
array(
'key' => 'US:00501',
),
),
),
)),
));
$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': {
'zips': [
{
'key': 'US:94304',
},
{
'key': 'US:00501',
},
],
},
},
})
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(2L)
.setDailyBudget(1000L)
.setCampaignId(<CAMPAIGN_ID>)
.setTargeting(
new Targeting()
.setFieldGeoLocations(
new TargetingGeoLocation()
.setFieldZips(Arrays.asList(
new TargetingGeoLocationZip()
.setFieldKey("US:94304")
,
new TargetingGeoLocationZip()
.setFieldKey("US:00501")
))
)
)
.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=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/v2.11/act_<AD_ACCOUNT_ID>/adsets
下列代碼用於設定目標:
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 => 2,
AdSetFields::DAILY_BUDGET => 1000,
AdSetFields::CAMPAIGN_ID => <CAMPAIGN_ID>,
AdSetFields::TARGETING => (new Targeting())->setData(array(
TargetingFields::GEO_LOCATIONS => array(
'custom_locations' => array(
array(
'address_string' => '1601 Willow Road, Menlo Park, CA',
'radius' => '5',
),
array(
'latitude' => '36',
'longitude' => '-121.0',
'radius' => '5',
'distance_unit' => 'kilometer',
),
),
'geo_markets' => array(
array(
'key' => 'DMA:501',
'name' => 'New York',
),
array(
'key' => 'DMA:543',
'name' => 'Springfield-Holyoke',
),
),
'location_types' => array('recent', 'home'),
),
)),
));
$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': {
'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'],
},
},
})
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(2L)
.setDailyBudget(1000L)
.setCampaignId(<CAMPAIGN_ID>)
.setTargeting(
new Targeting()
.setFieldGeoLocations(
new TargetingGeoLocation()
.setFieldCustomLocations(Arrays.asList(
new TargetingGeoLocationCustomLocation()
.setFieldAddressString("1601 Willow Road, Menlo Park, CA")
.setFieldRadius((double) 5)
,
new TargetingGeoLocationCustomLocation()
.setFieldDistanceUnit("kilometer")
.setFieldLatitude((double) 36)
.setFieldLongitude((double) -121.0)
.setFieldRadius((double) 5)
))
.setFieldGeoMarkets(Arrays.asList(
new TargetingGeoLocationMarket()
.setFieldKey("DMA:501")
.setFieldName("New York")
,
new TargetingGeoLocationMarket()
.setFieldKey("DMA:543")
.setFieldName("Springfield-Holyoke")
))
.setFieldLocationTypes(Arrays.asList("recent", "home"))
)
)
.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=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"}
],
"location_types": ["recent","home"]
}
}' \
-F 'status=ACTIVE' \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v2.11/act_<AD_ACCOUNT_ID>/adsets
要鎖定男性,年齡介於 20 至 24 歲,在 Menlo Park, CA 周圍 10 英里內,或住在德州或日本:
首先,取得日本的國碼/區碼:
use FacebookAds\Object\TargetingSearch;
use FacebookAds\Object\Search\TargetingSearchTypes;
$result = TargetingSearch::search(
TargetingSearchTypes::GEOLOCATION,
null,
'japan',
array(
'location_types' => array('country'),
));
from facebookads.adobjects.targetingsearch import TargetingSearch
params = {
'q': 'japan',
'type': 'adgeolocation',
'location_types': ['country'],
}
resp = TargetingSearch.search(params=params)
print(resp)
curl -G \
-d 'location_types=["country"]' \
-d 'type=adgeolocation' \
-d 'q=japan' \
-d 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v2.11/search
取得德州的區碼:
use FacebookAds\Object\TargetingSearch;
use FacebookAds\Object\Search\TargetingSearchTypes;
$result = TargetingSearch::search(
TargetingSearchTypes::GEOLOCATION,
null,
'texas',
array(
'location_types' => array('region'),
));
from facebookads.adobjects.targetingsearch import TargetingSearch
params = {
'q': 'texas',
'type': 'adgeolocation',
'location_types': ['region'],
}
resp = TargetingSearch.search(params=params)
print(resp)
curl -G \
-d 'location_types=["region"]' \
-d 'type=adgeolocation' \
-d 'q=texas' \
-d 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v2.11/search
搜尋 Menlo Park, CA 的城市代碼:
use FacebookAds\Object\TargetingSearch;
use FacebookAds\Object\Search\TargetingSearchTypes;
$result = TargetingSearch::search(
TargetingSearchTypes::GEOLOCATION,
null,
'menlo',
array(
'location_types' => array('city'),
));
from facebookads.adobjects.targetingsearch import TargetingSearch
params = {
'q': 'menlo',
'type': 'adgeolocation',
'location_types': ['city'],
}
resp = TargetingSearch.search(params=params)
print(resp)
curl -G \
-d 'location_types=["city"]' \
-d 'type=adgeolocation' \
-d 'q=menlo' \
-d 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v2.11/search
提供 genders
和年齡的 age_min
和 age_max
。
我們的目標設定規格已設有國碼、區碼及城市代碼:
use FacebookAds\Object\AdSet;
use FacebookAds\Object\Fields\AdSetFields;
use FacebookAds\Object\Fields\TargetingFields;
use FacebookAds\Object\Targeting;
use FacebookAds\Object\Values\AdSetOptimizationGoalValues;
use FacebookAds\Object\Values\AdSetBillingEventValues;
$adset = new AdSet(null, 'act_<AD_ACCOUNT_ID>');
$adset->setData(array(
AdSetFields::NAME => 'My First AdSet',
AdSetFields::DAILY_BUDGET => 10000,
AdSetFields::BID_AMOUNT => 300,
AdSetFields::BILLING_EVENT => AdSetBillingEventValues::IMPRESSIONS,
AdSetFields::OPTIMIZATION_GOAL => AdSetOptimizationGoalValues::REACH,
AdSetFields::CAMPAIGN_ID => <CAMPAIGN_ID>,
AdSetFields::PROMOTED_OBJECT => array(
'page_id' => <PAGE_ID>,
),
AdSetFields::TARGETING => (new Targeting())->setData(array(
TargetingFields::GEO_LOCATIONS => array(
'countries' => array('JP'),
'regions' => array(array('key' => '3886')),
'cities' => array(
array(
'key' => '2420605',
'radius' => 10,
'distance_unit' => 'mile',
),
),
),
TargetingFields::GENDERS => array(1),
TargetingFields::AGE_MIN => 20,
TargetingFields::AGE_MAX => 24,
TargetingFields::PUBLISHER_PLATFORMS => array(
'facebook',
'audience_network',
),
TargetingFields::DEVICE_PLATFORMS => array('mobile'),
)),
));
$adset->create(array(
AdSet::STATUS_PARAM_NAME => AdSet::STATUS_PAUSED,
));
from facebookads.adobjects.adset import AdSet
from facebookads.adobjects.targeting import Targeting
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.promoted_object: {'page_id': <PAGE_ID>},
AdSet.Field.targeting: {
Targeting.Field.geo_locations: {
'countries': ['JP'],
'regions': [
{'key': '3886'},
],
'cities': [
{
'key': '2420605',
'radius': '10',
'distance_unit': 'mile',
},
],
},
Targeting.Field.genders: [1],
Targeting.Field.age_min: 20,
Targeting.Field.age_max: 24,
Targeting.Field.publisher_platforms: ['facebook', 'audience_network'],
Targeting.Field.device_platforms: ['mobile'],
},
})
adset.remote_create(params={
'status': AdSet.Status.active,
})
AdSet adSet = new AdAccount(act_<AD_ACCOUNT_ID>, context).createAdSet()
.setName("My First AdSet")
.setDailyBudget(10000L)
.setBidAmount(300L)
.setBillingEvent(AdSet.EnumBillingEvent.VALUE_IMPRESSIONS)
.setOptimizationGoal(AdSet.EnumOptimizationGoal.VALUE_REACH)
.setCampaignId(<CAMPAIGN_ID>)
.setPromotedObject("{\"page_id\":\"" + <PAGE_ID> + "\"}")
.setTargeting(
new Targeting()
.setFieldAgeMax(24L)
.setFieldAgeMin(20L)
.setFieldDevicePlatforms(Arrays.asList(Targeting.EnumDevicePlatforms.VALUE_MOBILE))
.setFieldGenders(Arrays.asList(1L))
.setFieldGeoLocations(
new TargetingGeoLocation()
.setFieldCities(Arrays.asList(
new TargetingGeoLocationCity()
.setFieldDistanceUnit("mile")
.setFieldKey("2420605")
.setFieldRadius(10L)
))
.setFieldCountries(Arrays.asList("JP"))
.setFieldRegions(Arrays.asList(
new TargetingGeoLocationRegion()
.setFieldKey("3886")
))
)
.setFieldPublisherPlatforms(Arrays.asList("facebook", "audience_network"))
)
.setStatus(AdSet.EnumStatus.VALUE_PAUSED)
.execute();
String ad_set_id = adSet.getId();
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/v2.11/act_<AD_ACCOUNT_ID>/adsets
將 custom_type
設為 'multi_city'
並依此處所述定義 country
或 country_group
。其他選用參數如下所示:
名稱 | 說明 |
---|---|
| 選定進行目標設定之城市的最低人口閾值。 |
| 選定進行目標設定之城市的最高人口閾值。 |
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();
$adset->setParentId('act_<AD_ACCOUNT_ID>');
$adset->setData(array(
AdSetFields::NAME => 'My AdSet',
AdSetFields::OPTIMIZATION_GOAL => AdSetOptimizationGoalValues::REACH,
AdSetFields::BILLING_EVENT => AdSetBillingEventValues::IMPRESSIONS,
AdSetFields::BID_AMOUNT => 2,
AdSetFields::DAILY_BUDGET => 1000,
AdSetFields::CAMPAIGN_ID => <CAMPAIGN_ID>,
AdSetFields::TARGETING => (new Targeting())->setData(array(
TargetingFields::GEO_LOCATIONS => array(
'custom_locations' => array(
array(
'custom_type' => 'multi_city',
'min_population' => 500000,
'max_population' => 1000000,
'country' => 'BR',
),
array(
'custom_type' => 'multi_city',
'country_group' => 'Europe',
),
),
'location_types' => array('recent', 'home'),
),
)),
));
$adset->create(array(
AdSet::STATUS_PARAM_NAME => AdSet::STATUS_ACTIVE,
));
from facebookads.adobjects.adaccount import AdAccount
from facebookads.adobjects.adset import AdSet
ad_account = AdAccount(fbid='act_<AD_ACCOUNT_ID>')
params = {
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': {
'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'],
},
},
AdSet.Field.status: AdSet.Status.active,
}
adset = ad_account.create_ad_set(params=params)
AdSet adSet = new AdAccount(act_<AD_ACCOUNT_ID>, context).createAdSet()
.setName("My First AdSet")
.setDailyBudget(10000L)
.setBidAmount(300L)
.setBillingEvent(AdSet.EnumBillingEvent.VALUE_IMPRESSIONS)
.setOptimizationGoal(AdSet.EnumOptimizationGoal.VALUE_REACH)
.setCampaignId(<CAMPAIGN_ID>)
.setPromotedObject("{\"page_id\":\"" + <PAGE_ID> + "\"}")
.setTargeting(
new Targeting()
.setFieldAgeMax(24L)
.setFieldAgeMin(20L)
.setFieldDevicePlatforms(Arrays.asList(Targeting.EnumDevicePlatforms.VALUE_MOBILE))
.setFieldGenders(Arrays.asList(1L))
.setFieldGeoLocations(
new TargetingGeoLocation()
.setFieldCustomLocations(Arrays.asList(
new TargetingGeoLocationCustomLocation()
.setFieldCountry("BR")
.setFieldCustomType("multi_city")
.setFieldMaxPopulation(1000000L)
.setFieldMinPopulation(500000L)
,
new TargetingGeoLocationCustomLocation()
.setFieldCountryGroup("Asia")
.setFieldCustomType("multi_city")
))
.setFieldLocationTypes(Arrays.asList("recent", "home"))
)
.setFieldPublisherPlatforms(Arrays.asList("facebook", "audience_network"))
)
.setStatus(AdSet.EnumStatus.VALUE_PAUSED)
.execute();
String ad_set_id = adSet.getId();
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/v2.11/act_<AD_ACCOUNT_ID>/adsets
根據用戶動態時報中的興趣、按讚的粉絲專頁,或與其使用的粉絲專頁或應用程式相關的關鍵字等條件進行目標設定。請參閱目標設定搜尋:興趣。
若要鎖定對足球有興趣的用戶,請先查詢:
use FacebookAds\Object\TargetingSearch;
use FacebookAds\Object\Search\TargetingSearchTypes;
$result = TargetingSearch::search(
TargetingSearchTypes::INTEREST,
null,
'soccer');
from facebookads.adobjects.targetingsearch import TargetingSearch
params = {
'q': 'soccer',
'type': 'adinterest',
}
resp = TargetingSearch.search(params=params)
print(resp)
curl -G \
-d 'type=adinterest' \
-d 'q=soccer' \
-d 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v2.11/search
將興趣的 name
和 id
新增至目標設定規格,其中 path
為興趣在廣告工具中的路徑。
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="<AD_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/v21.0/act_<AD_ACCOUNT_ID>/adsets
以下為另一個範例:
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 => 2,
AdSetFields::DAILY_BUDGET => 1000,
AdSetFields::CAMPAIGN_ID => <CAMPAIGN_ID>,
AdSetFields::TARGETING => (new Targeting())->setData(array(
TargetingFields::GEO_LOCATIONS => array(
'countries' => array(
'US',
),
),
TargetingFields::INTERESTS => array(
array(
'id' => 6003139266461,
'name' => 'Movies',
),
array(
'id' => 6003397425735,
'name' => 'Tennis',
),
array(
'id' => 6003659420716,
'name' => 'Cooking',
),
),
)),
));
$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'],
},
'interests': [
{
'id': 6003139266461,
'name': 'Movies',
},
{
'id': 6003397425735,
'name': 'Tennis',
},
{
'id': 6003659420716,
'name': 'Cooking',
},
],
},
})
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(2L)
.setDailyBudget(1000L)
.setCampaignId(<CAMPAIGN_ID>)
.setTargeting(
new Targeting()
.setFieldGeoLocations(
new TargetingGeoLocation()
.setFieldCountries(Arrays.asList("US"))
)
.setFieldInterests(Arrays.asList(
new IDName()
.setFieldId("6003139266461")
.setFieldName("Movies")
,
new IDName()
.setFieldId("6003397425735")
.setFieldName("Tennis")
,
new IDName()
.setFieldId("6003659420716")
.setFieldName("Cooking")
))
)
.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=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/v2.11/act_<AD_ACCOUNT_ID>/adsets
名稱 | 說明 |
---|---|
| 設有「編號」及選用「名稱」欄位的陣列: |
根據數位動態、用戶所使用的裝置、過去或計劃中的訂單,以及旅遊設定目標。檢視 Browse
的選項,例如經常旅行的用戶。請參閱目標設定搜尋 API。
use FacebookAds\Object\TargetingSearch;
use FacebookAds\Object\Search\TargetingSearchTypes;
$result = TargetingSearch::search(
TargetingSearchTypes::TARGETING_CATEGORY,
'behaviors');
from facebookads.adobjects.targetingsearch import TargetingSearch
params = {
'type': 'adTargetingCategory',
'class': 'behaviors',
}
resp = TargetingSearch.search(params=params)
print(resp)
curl -G \
-d 'type=adTargetingCategory' \
-d 'class=behaviors' \
-d 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v2.11/search
新增行為至 targeting_spec
:
use FacebookAds\Object\AdSet;
use FacebookAds\Object\Fields\AdSetFields;
use FacebookAds\Object\Fields\TargetingFields;
use FacebookAds\Object\Targeting;
use FacebookAds\Object\Values\AdSetOptimizationGoalValues;
use FacebookAds\Object\Values\AdSetBillingEventValues;
$adset = new AdSet(null, 'act_<AD_ACCOUNT_ID>');
$adset->setData(array(
AdSetFields::NAME => 'My First AdSet',
AdSetFields::DAILY_BUDGET => 10000,
AdSetFields::BID_AMOUNT => 300,
AdSetFields::BILLING_EVENT => AdSetBillingEventValues::IMPRESSIONS,
AdSetFields::OPTIMIZATION_GOAL => AdSetOptimizationGoalValues::REACH,
AdSetFields::CAMPAIGN_ID => <CAMPAIGN_ID>,
AdSetFields::PROMOTED_OBJECT => array(
'page_id' => <PAGE_ID>,
),
AdSetFields::TARGETING => (new Targeting())->setData(array(
TargetingFields::GEO_LOCATIONS => array(
'countries' => array('JP'),
'regions' => array(array('key' => '3886')),
'cities' => array(
array(
'key' => '2420605',
'radius' => 10,
'distance_unit' => 'mile',
),
),
),
TargetingFields::GENDERS => array(1),
TargetingFields::AGE_MIN => 20,
TargetingFields::AGE_MAX => 24,
TargetingFields::PUBLISHER_PLATFORMS => array(
'facebook',
'audience_network',
),
TargetingFields::DEVICE_PLATFORMS => array('mobile'),
TargetingFields::INTERESTS => array(
array(
'id' => 6003107902433,
'name' => 'Association football (Soccer)',
),
),
TargetingFields::BEHAVIORS => array(
array(
'id' => 6002714895372,
'name' => 'All frequent travelers',
),
),
)),
));
$adset->create(array(
AdSet::STATUS_PARAM_NAME => AdSet::STATUS_PAUSED,
));
from facebookads.adobjects.adset import AdSet
from facebookads.adobjects.targeting import Targeting
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.promoted_object: {'page_id': <PAGE_ID>},
AdSet.Field.targeting: {
Targeting.Field.geo_locations: {
'countries': ['JP'],
'regions': [
{'key': '3886'},
],
'cities': [
{
'key': '2420605',
'radius': '10',
'distance_unit': 'mile',
},
],
},
Targeting.Field.genders: [1],
Targeting.Field.age_min: 20,
Targeting.Field.age_max: 24,
Targeting.Field.publisher_platforms: ['facebook', 'audience_network'],
Targeting.Field.device_platforms: ['mobile'],
Targeting.Field.interests: [
{
'id': 6003107902433,
'name': 'Association football (Soccer)',
},
],
Targeting.Field.behaviors: [
{
'id': 6002714895372,
'name': 'All frequent travelers',
},
],
},
})
adset.remote_create(params={
'status': AdSet.Status.active,
})
AdSet adSet = new AdAccount(act_<AD_ACCOUNT_ID>, context).createAdSet()
.setName("My First AdSet")
.setDailyBudget(10000L)
.setBidAmount(300L)
.setBillingEvent(AdSet.EnumBillingEvent.VALUE_IMPRESSIONS)
.setOptimizationGoal(AdSet.EnumOptimizationGoal.VALUE_REACH)
.setCampaignId(<CAMPAIGN_ID>)
.setPromotedObject("{\"page_id\":\"" + <PAGE_ID> + "\"}")
.setTargeting(
new Targeting()
.setFieldAgeMax(24L)
.setFieldAgeMin(20L)
.setFieldBehaviors(Arrays.asList(
new IDName()
.setFieldId("6002714895372")
.setFieldName("All frequent travelers")
))
.setFieldDevicePlatforms(Arrays.asList(Targeting.EnumDevicePlatforms.VALUE_MOBILE))
.setFieldGenders(Arrays.asList(1L))
.setFieldGeoLocations(
new TargetingGeoLocation()
.setFieldCities(Arrays.asList(
new TargetingGeoLocationCity()
.setFieldDistanceUnit("mile")
.setFieldKey("2420605")
.setFieldRadius(10L)
))
.setFieldCountries(Arrays.asList("JP"))
.setFieldRegions(Arrays.asList(
new TargetingGeoLocationRegion()
.setFieldKey("3886")
))
)
.setFieldInterests(Arrays.asList(
new IDName()
.setFieldId("6003107902433")
.setFieldName("Association football (Soccer)")
))
.setFieldPublisherPlatforms(Arrays.asList("facebook", "audience_network"))
)
.setStatus(AdSet.EnumStatus.VALUE_PAUSED)
.execute();
String ad_set_id = adSet.getId();
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/v2.11/act_<AD_ACCOUNT_ID>/adsets
以下為另一個範例:
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="<AD_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/v21.0/act_<AD_ACCOUNT_ID>/adsets
名稱 | 說明 |
---|---|
| 設有「編號」及選用「名稱」欄位的陣列: |
其他目標設定: