La segmentación básica o principal incluye:
Los anunciantes que ponen en circulación anuncios de vivienda, empleo, crédito, temas sociales, elecciones o política con sede en los Estados Unidos o que muestran anuncios dirigidos a los Estados Unidos tienen un conjunto de restricciones distinto.
Comienza con la segmentación básica según los datos demográficos y la ubicación. Por lo general, debes obtener los datos para definir la segmentación de Búsqueda de segmentación y, a continuación, especificar las opciones en las especificaciones de segmentación. Las especificaciones de segmentación son atributos de conjunto de anuncios que definen quién ve un anuncio.
Debes especificar al menos un país en la segmentación, salvo que utilices audiencias personalizadas.
Segmentación por datos demográficos:
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
Nombre | Descripción |
---|---|
| Géneros a los que dirigirse. El valor predeterminado los incluye todos. |
| Edad mínima. El valor predeterminado es 18. Si se utiliza, debe ser 13 o superior. Si la aplicación tiene una configuración personalizada para las restricciones de edad, se usarán dichas restricciones para los anuncios con objetivos APP_INSTALL. Por ejemplo, si defines el valor de |
| Edad máxima. Si se utiliza, debe ser 65 o inferior. |
Busca y recupera valores para la segmentación por lugar en la API de búsqueda de segmentación. Esta segmentación presenta dos parámetros: geo_locations
para segmentar ubicaciones y, de manera opcional, excluded_geo_locations
para excluir zonas.
Usa country_groups
para geo_locations
a fin de segmentar regiones geográficas más amplias, como Europa o Norteamérica.
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.
Nombre | Descripción |
---|---|
| Segmentación por país. Requiere la matriz de códigos de país. Búsqueda de segmentación, Países. Ejemplo: |
| Estado, provincia o región. Para conocer los valores disponibles, consulta Búsqueda de segmentación, Regiones. Límite: 200. |
| Especifica |
| Segmentación por código postal. Consulta API de búsqueda de segmentación. Límite: 50 000. Anteriormente, 2500. Si proporcionas un valor superior a 2500, se crea una matriz denominada Para leer una matriz |
| Proporciona un lugar específico. Límite: 200. Ejemplo: |
| Disponible para todos los objetivos. Proporciona la ubicación exacta en latitud y longitud, o la dirección como el centro de un área. Especifica también el radio de tu ubicación de 0,63 a 50 millas o de 1 a 80 kilómetros. La unidad de |
| Latitud de la ubicación |
| Longitud de la ubicación |
| Nombre de la dirección. Se puede utilizar con los valores de |
| Radio en torno a la latitud o la longitud en millas, salvo que se indique de otro modo en |
| Opcional.
|
| Dirección en latitud/longitud, como 1601 Willow Rd, Menlo Park, CA. Formato sugerido: número de la calle, nombre de la calle, ciudad, estado/provincia, país. Excluye los códigos postales. |
| Clave del mercado, con el formato “DMA:501”. Se admiten todas las áreas de mercado designadas (DMA). Obtén los códigos DMA en Búsqueda de segmentación mediante una consulta por nombre de DMA. Límite: 2500 |
| Clave de los distritos electorales. Obtén distritos en Búsqueda de segmentación, Distritos electorales. |
| Nota: A partir de la versión 18.0, la matriz En el caso de las versiones posteriores a la versión 18.0, si no se proporciona
|
| Regiones geográficas globales y áreas de libre comercio. Proporciona la matriz de códigos de grupos de países:
Consulta Búsqueda de segmentación, Grupos de países. Ejemplo: |
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
El código siguiente configura la segmentación para:
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
Para dirigirte a hombres de 20 a 24 años de edad en un radio de 10 millas alrededor de Menlo Park, CA o que residan en Texas o Japón:
En primer lugar, obtén el código de país de Japón:
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
Obtén el código de región de Texas:
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
Busca el código de ciudad de 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
Indica el valor de genders
y especifica los valores de edad age_min
y age_max
.
Nuestra especificación de segmentación está lista con los códigos de país, región y ciudad:
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
Establece custom_type
en 'multi_city'
y define country
o country_group
como hemos descrito anteriormente. Los parámetros adicionales opcionales son:
Nombre | Descripción |
---|---|
| El umbral de población mínimo a la hora de seleccionar ciudades para la segmentación. |
| El umbral de población máximo a la hora de seleccionar ciudades para la segmentación. |
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
Realiza la segmentación según los intereses de la biografía de alguien; p. ej., a partir de las páginas en las que ha indicado Me gusta o de las palabras clave asociadas con las páginas o las aplicaciones que utiliza. Consulta Búsqueda de segmentación, Intereses.
Para dirigirte a personas interesadas en el fútbol, consulta primero:
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
Añade este interés por name
e id
a una especificación de segmentación, donde path
sea la ruta de este interés en las herramientas de anuncios.
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
A continuación se muestra otro ejemplo:
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
Nombre | Descripción |
---|---|
| Matriz con el campo “id” y el campo opcional “name”: |
Realiza la segmentación por las actividades digitales, los dispositivos que emplean los usuarios, las compras pasadas o previstas, y los viajes. Consulta las opciones en Browse
; p. ej., Viajeros frecuentes. Consulta API de búsqueda de segmentación.
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
Añade el comportamiento a 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
Otro ejemplo:
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
Nombre | Descripción |
---|---|
| Matriz con el campo “id” y el campo opcional “name”: |
Otros tipos de segmentación: