本指南假定您拥有旅游库存目录,且已经为网站或移动应用设置了所需的旅游事件,同时已经关联目录和事件源。
自 2018 年 9 月 20 日起,对于市场营销 API 3.0 之后的版本,我们将不再为网站和应用的自定义受众、互动自定义受众以及线下转化数据受众提供 subtype
支持。唯一的例外是视频的互动自定义受众,我们仍将为其提供 subtype
支持。
两步创建旅游受众:
除了关联目录和事件源,您还必须创建事件源组。事件源组将用于填充受众。
use FacebookAds\Object\EventSourceGroup;
use FacebookAds\Object\Fields\EventSourceGroupFields;
$event_source_group = new EventSourceGroup(null, <BUSINESS_ID>);
$event_source_group->setData(array(
EventSourceGroupFields::NAME => 'My Travel Company Events',
EventSourceGroupFields::EVENT_SOURCES => array(
<PIXEL_ID>,
<APP_ID>,
),
));
$event_source_group->create();
from facebookads.adobjects.eventsourcegroup import EventSourceGroup
event_source_group = EventSourceGroup(parent_id=<BUSINESS_ID>)
event_source_group[EventSourceGroup.Field.name] = 'My Travel Company Events'
event_source_group[EventSourceGroup.Field.event_sources] = [
<PIXEL_ID>,
<APP_ID>,
]
event_source_group.remote_create()
curl \
-F 'name=My Travel Company Events' \
-F 'event_sources=["<PIXEL_ID>","<APP_ID>"]' \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v2.11/<BUSINESS_ID>/event_source_groups
然后,您必须将此事件源组分享给任何希望创建受其支持的受众的广告帐户。同样,可以通过执行 HTTP POST
调用来完成此操作:
use FacebookAds\Object\EventSourceGroup;
$event_source_group = new EventSourceGroup(<EVENT_SOURCE_GROUP_ID>);
// ad account id without 'act_'
$event_source_group->createSharedAccount(array(), array(
'accounts' => array(
'<ACCOUNT_ID_WITHOUT_ACT>',
),
));
from facebookads.adobjects.eventsourcegroup import EventSourceGroup
event_source_group = EventSourceGroup(<EVENT_SOURCE_GROUP_ID>)
# ad account id without 'act_'
response = event_source_group.create_shared_account(
params={
'accounts': ['<ACCOUNT_ID_WITHOUT_ACT>'],
},
)
print(response)
curl \
-F 'accounts=["<ACCOUNT_ID_WITHOUT_ACT>"]' \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v2.11/<EVENT_SOURCE_GROUP_ID>/shared_accounts
此时,您应该已设置用户信号(即,Pixel 像素代码事件和/或应用事件)并将其与事件源组和您的旅游目录相关联。
如要定位已表现出明确旅游意向的用户,您必须创建一组动态旅游受众,以便向其投放广告。您可以根据用户的旅游意向信号来添加和排除用户。除事件以外,您还可以应用其他基于规则的筛选条件,例如“网站自定义受众”。对于动态航班受众,flight_set_id
字段是必要项。对于酒店和目的地受众,您无需指定 hotel_set_id
或 destination_set_id
。
如要设置新的旅游受众,请向 /act_<AD_ACCOUNT_ID>/customaudiences
发出 HTTP POST
。
字段名称和类型 | 描述 |
---|---|
类型: | 必要。 受众的目标。 必须设置为 |
类型: | 必要。 指定用于构建此受众的信号类型。 必须设置为 |
类型: | 包含 "event_sources": [ { "type": "pixel", "id": "562030684179932" }, { "type": "app", "id": "562030684179934" } ] 如果未提供 |
类型: | 指定其事件将支持受众的事件源组。如果未提供 |
类型: | 必要。 JSON 对象数组,列出可让帐户管理中心帐户有资格成为相关受众的所有意向信号。请参阅下文的添加对象参数表格。 |
类型: | 对受众的进一步描述。 |
类型: | JSON 对象数组,列出将符合条件的帐户管理中心帐户从相关受众中排除的所有意向信号。请参阅下文的排除对象参数表格。 |
类型: | 在处理任何 |
字段名称和类型 | 描述 |
---|---|
类型: | 必要。 您想要添加的信号的事件名称。 示例: |
类型: | 必要。 自从接收事件后,将其用作添加用户到受众范围的依据的最短/最长时间。留存期限必须至少为 4 个小时。 请参阅下文的留存对象参数表格。 示例: |
类型: | 预订时段指用户入住日期与当前日期之间的时间(以秒为单位)。您指定时间范围后,系统仅会将预订时段在此范围内的用户添加为受众。此外,我们也支持预订时段为负数,让您能将入住日期在过去的用户添加为受众。 请参阅下文的预订时段对象参数表格。 示例:
|
类型: | 事件被触发的次数。您可以在此处使用等式运算符和数值比较运算符。 示例: |
字段名称和类型 | 描述 |
---|---|
类型: | 必要。 自从接收事件起的最长时间(以秒为单位)。 示例: |
类型: | 自从接收事件起的最短时间(以秒为单位)。 示例: |
字段名称和类型 | 描述 |
---|---|
类型: | 必要。 当前日期和用户预期入住日期之间的最短时间(以秒为单位)。 示例: |
类型: | 必要。 当前日期和用户预期入住日期之间的最长时间(以秒为单位)。 示例: |
字段名称和类型 | 描述 |
---|---|
类型: | 必要。 与您想要排除的信号相关的事件名称。 示例: |
类型: | 必要。 自从接收事件后,将其用作从受众范围排除用户的依据的最短/最长时间。留存期限必须至少为 4 个小时。 请参阅下文的留存对象参数表格。 示例: |
与典型参数一样,每一个旅游参数都可与任何标准的 JSON
运算符一起使用。
字段名称和类型 | 描述 |
---|---|
类型: | 当指定的 仅适用于 示例: |
类型: | 仅匹配在指定的 仅适用于 示例: |
类型: | 对于航班广告为必要项。 仅匹配指定的 仅适用于 示例: |
类型: | 旅行期间的入住晚数。 示例: |
类型: | 自开始至结束日期之间的周末数 示例: |
类型: | 旅客总人数
示例: |
日期字段:
类型: | 根据 示例: |
类型: | 旅行包含具体日期。 示例: |
过去 5 天至少搜索过 3 次但未预订的单独旅行者:
use FacebookAds\Object\CustomAudience;
use FacebookAds\Object\Fields\CustomAudienceFields;
use FacebookAds\Object\Values\CustomAudienceSubtypeValues;
use FacebookAds\Object\Values\CustomAudienceClaimObjectiveValues;
use FacebookAds\Object\Values\CustomAudienceContentTypeValues;
$custom_audience = new CustomAudience(null, 'act_<AD_ACCOUNT_ID>');
$custom_audience->setData(array(
CustomAudienceFields::NAME => 'Travel Audience',
CustomAudienceFields::SUBTYPE => CustomAudienceSubtypeValues::CLAIM,
CustomAudienceFields::CLAIM_OBJECTIVE =>
CustomAudienceClaimObjectiveValues::TRAVEL,
CustomAudienceFields::CONTENT_TYPE => CustomAudienceContentTypeValues::HOTEL,
CustomAudienceFields::EVENT_SOURCE_GROUP => <EVENT_SOURCE_GROUP_ID>,
CustomAudienceFields::RULE => array(
'num_travelers' => array('eq' => 1),
),
'inclusions' => array(
array(
'event' => 'Search',
'count' => array('gt' => 3),
'retention' => array('min_seconds'=> 0, 'max_seconds'=> 432000),
),
),
'exclusions' => array(
array(
'event' => 'Purchase',
'retention' => array('min_seconds'=> 0, 'max_seconds'=> 172800),
),
),
));
$custom_audience->create();
from facebookads.adobjects.customaudience import CustomAudience
audience = CustomAudience(parent_id='act_<AD_ACCOUNT_ID>')
audience[CustomAudience.Field.name] = 'Travel Audience'
audience[CustomAudience.Field.subtype] = CustomAudience.Subtype.claim
audience[CustomAudience.Field.claim_objective] = \
CustomAudience.ClaimObjective.travel
audience[CustomAudience.Field.content_type] = CustomAudience.ContentType.hotel
audience[CustomAudience.Field.event_source_group] = <EVENT_SOURCE_GROUP_ID>
audience[CustomAudience.Field.rule] = {
'num_travelers': {'eq': 1},
}
audience['inclusions'] = [
{
'event': 'Search',
'count': {'gt': 3},
'retention': {'min_seconds': 0, 'max_seconds': 432000},
},
]
audience['exclusions'] = [
{
'event': 'Purchase',
'retention': {'min_seconds': 0, 'max_seconds': 432000},
},
]
audience.remote_create()
curl \
-F 'name=Travel Audience' \
-F 'subtype=CLAIM' \
-F 'claim_objective=TRAVEL' \
-F 'content_type=HOTEL' \
-F 'event_source_group=<EVENT_SOURCE_GROUP_ID>' \
-F 'rule={"num_travelers":{"eq":1}}' \
-F 'inclusions=[
{
"event": "Search",
"count": {"gt":3},
"retention": {"min_seconds":0,"max_seconds":432000}
}
]' \
-F 'exclusions=[{"event":"Purchase","retention":{"min_seconds":0,"max_seconds":172800}}]' \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v2.11/act_<AD_ACCOUNT_ID>/customaudiences
过去 2 天内查看或开始预订酒店系列中的酒店但未完成预订的用户:
use FacebookAds\Object\CustomAudience;
use FacebookAds\Object\Fields\CustomAudienceFields;
use FacebookAds\Object\Values\CustomAudienceSubtypeValues;
use FacebookAds\Object\Values\CustomAudienceClaimObjectiveValues;
use FacebookAds\Object\Values\CustomAudienceContentTypeValues;
$custom_audience = new CustomAudience(null, 'act_<AD_ACCOUNT_ID>');
$custom_audience->setData(array(
CustomAudienceFields::NAME => 'Travel Audience',
CustomAudienceFields::SUBTYPE => CustomAudienceSubtypeValues::CLAIM,
CustomAudienceFields::CLAIM_OBJECTIVE =>
CustomAudienceClaimObjectiveValues::TRAVEL,
CustomAudienceFields::CONTENT_TYPE => CustomAudienceContentTypeValues::HOTEL,
CustomAudienceFields::EVENT_SOURCE_GROUP => <EVENT_SOURCE_GROUP_ID>,
CustomAudienceFields::RULE => array(
'hotel_set_id' => array('eq' => <HOTEL_SET_ID>),
),
'inclusions' => array(
array(
'event' => 'ViewContent',
'retention' => array('min_seconds'=> 0, 'max_seconds'=> 172800),
),
array(
'event' => 'InitiateCheckout',
'retention' => array('min_seconds'=> 0, 'max_seconds'=> 172800),
),
),
'exclusions' => array(
array(
'event' => 'Purchase',
'retention' => array('min_seconds'=> 0, 'max_seconds'=> 172800),
),
),
));
$custom_audience->create();
from facebookads.adobjects.customaudience import CustomAudience
audience = CustomAudience(parent_id='act_<AD_ACCOUNT_ID>')
audience[CustomAudience.Field.name] = 'Travel Audience'
audience[CustomAudience.Field.subtype] = CustomAudience.Subtype.claim
audience[CustomAudience.Field.claim_objective] = \
CustomAudience.ClaimObjective.travel
audience[CustomAudience.Field.content_type] = CustomAudience.ContentType.hotel
audience[CustomAudience.Field.event_source_group] = <EVENT_SOURCE_GROUP_ID>
audience[CustomAudience.Field.rule] = {
'hotel_set_id': {'eq': <HOTEL_SET_ID>},
}
audience['inclusions'] = [
{
'event': 'ViewContent',
'retention': {'min_seconds': 0, 'max_seconds': 172800},
},
{
'event': 'InitiateCheckout',
'retention': {'min_seconds': 0, 'max_seconds': 172800},
},
]
audience['exclusions'] = [
{
'event': 'Purchase',
'retention': {'min_seconds': 0, 'max_seconds': 172800},
},
]
audience.remote_create()
curl \
-F 'name=Travel Audience' \
-F 'subtype=CLAIM' \
-F 'claim_objective=TRAVEL' \
-F 'content_type=HOTEL' \
-F 'event_source_group=<EVENT_SOURCE_GROUP_ID>' \
-F 'rule={"hotel_set_id":{"eq":"<HOTEL_SET_ID>"}}' \
-F 'inclusions=[
{"event":"ViewContent","retention":{"min_seconds":0,"max_seconds":172800}},
{
"event": "InitiateCheckout",
"retention": {"min_seconds":0,"max_seconds":172800}
}
]' \
-F 'exclusions=[{"event":"Purchase","retention":{"min_seconds":0,"max_seconds":172800}}]' \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v2.10/act_<AD_ACCOUNT_ID>/customaudiences
过去 5 天内已开始退房或购买机票,且航班预订时段介于 2 到 7 天之间的用户:
use FacebookAds\Object\CustomAudience;
use FacebookAds\Object\Fields\CustomAudienceFields;
use FacebookAds\Object\Values\CustomAudienceSubtypeValues;
use FacebookAds\Object\Values\CustomAudienceClaimObjectiveValues;
use FacebookAds\Object\Values\CustomAudienceContentTypeValues;
$custom_audience = new CustomAudience(null, 'act_<AD_ACCOUNT_ID>');
$custom_audience->setData(array(
CustomAudienceFields::NAME => 'Travel Audience',
CustomAudienceFields::SUBTYPE => CustomAudienceSubtypeValues::CLAIM,
CustomAudienceFields::CLAIM_OBJECTIVE =>
CustomAudienceClaimObjectiveValues::TRAVEL,
CustomAudienceFields::CONTENT_TYPE => CustomAudienceContentTypeValues::FLIGHT,
CustomAudienceFields::EVENT_SOURCE_GROUP => <EVENT_SOURCE_GROUP_ID>,
'inclusions' => array(
array(
'event' => 'InitiateCheckout',
'retention' => array('min_seconds'=> 0, 'max_seconds'=> 432000),
'booking_window' => array('min_seconds'=> 172800, 'max_seconds'=> 604800),
),
array(
'event' => 'Purchase',
'retention' => array('min_seconds'=> 0, 'max_seconds'=> 432000),
'booking_window' => array('min_seconds'=> 172800, 'max_seconds'=> 604800),
),
),
));
$custom_audience->create();
from facebookads.adobjects.customaudience import CustomAudience
audience = CustomAudience(parent_id='act_<AD_ACCOUNT_ID>')
audience[CustomAudience.Field.name] = 'Travel Audience'
audience[CustomAudience.Field.subtype] = CustomAudience.Subtype.claim
audience[CustomAudience.Field.claim_objective] = \
CustomAudience.ClaimObjective.travel
audience[CustomAudience.Field.content_type] = CustomAudience.ContentType.flight
audience[CustomAudience.Field.event_source_group] = <EVENT_SOURCE_GROUP_ID>
audience['inclusions'] = [
{
"event": "InitiateCheckout",
"retention": {"min_seconds": 0, "max_seconds": 432000},
"booking_window": {"min_seconds": 172800, "max_seconds": 604800},
},
{
"event": "Purchase",
"retention": {"min_seconds": 0, "max_seconds": 432000},
"booking_window": {"min_seconds": 172800, "max_seconds": 604800},
},
]
audience.remote_create()
curl \
-F 'name=Travel Audience' \
-F 'subtype=CLAIM' \
-F 'claim_objective=TRAVEL' \
-F 'content_type=FLIGHT' \
-F 'event_source_group=<EVENT_SOURCE_GROUP_ID>' \
-F 'inclusions=[
{
"event": "InitiateCheckout",
"retention": {"min_seconds":0,"max_seconds":432000},
"booking_window": {"min_seconds":172800,"max_seconds":604800}
},
{
"event": "Purchase",
"retention": {"min_seconds":0,"max_seconds":432000},
"booking_window": {"min_seconds":172800,"max_seconds":604800}
}
]' \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v2.11/act_<AD_ACCOUNT_ID>/customaudiences
过去 2 天内搜索位于“纽约市”的酒店超过 3 次但未预订的用户:
use FacebookAds\Object\CustomAudience;
use FacebookAds\Object\Fields\CustomAudienceFields;
use FacebookAds\Object\Values\CustomAudienceSubtypeValues;
use FacebookAds\Object\Values\CustomAudienceClaimObjectiveValues;
use FacebookAds\Object\Values\CustomAudienceContentTypeValues;
$custom_audience = new CustomAudience(null, 'act_<AD_ACCOUNT_ID>');
$custom_audience->setData(array(
CustomAudienceFields::NAME => 'Travel Audience',
CustomAudienceFields::SUBTYPE => CustomAudienceSubtypeValues::CLAIM,
CustomAudienceFields::CLAIM_OBJECTIVE =>
CustomAudienceClaimObjectiveValues::TRAVEL,
CustomAudienceFields::CONTENT_TYPE => CustomAudienceContentTypeValues::HOTEL,
CustomAudienceFields::EVENT_SOURCE_GROUP => <EVENT_SOURCE_GROUP_ID>,
CustomAudienceFields::RULE => array(
'destination' => array('i_contains' => 'New York City'),
),
'inclusions' => array(
array(
'event' => 'Search',
'count' => array('gt' => 3),
'retention' => array('min_seconds'=> 0, 'max_seconds'=> 172800),
),
),
'exclusions' => array(
array(
'event' => 'Purchase',
'retention' => array('min_seconds'=> 0, 'max_seconds'=> 172800),
),
),
));
$custom_audience->create();
from facebookads.adobjects.customaudience import CustomAudience
audience = CustomAudience(parent_id='act_<AD_ACCOUNT_ID>')
audience[CustomAudience.Field.name] = 'Travel Audience'
audience[CustomAudience.Field.subtype] = CustomAudience.Subtype.claim
audience[CustomAudience.Field.claim_objective] = \
CustomAudience.ClaimObjective.travel
audience[CustomAudience.Field.content_type] = CustomAudience.ContentType.hotel
audience[CustomAudience.Field.event_source_group] = <EVENT_SOURCE_GROUP_ID>
audience[CustomAudience.Field.rule] = {
'destination': {'i_contains': 'New York City'},
}
audience['inclusions'] = [
{
'event': 'Search',
'count': {'gt': 3},
'retention': {'min_seconds': 0, 'max_seconds': 172800},
},
]
audience['exclusions'] = [
{
'event': 'Purchase',
'retention': {'min_seconds': 0, 'max_seconds': 172800},
},
]
audience.remote_create()
curl \
-F 'name=Travel Audience' \
-F 'subtype=CLAIM' \
-F 'claim_objective=TRAVEL' \
-F 'content_type=HOTEL' \
-F 'event_source_group=<EVENT_SOURCE_GROUP_ID>' \
-F 'rule={"destination":{"i_contains":"New York City"}}' \
-F 'inclusions=[
{
"event": "Search",
"count": {"gt":3},
"retention": {"min_seconds":0,"max_seconds":172800}
}
]' \
-F 'exclusions=[{"event":"Purchase","retention":{"min_seconds":0,"max_seconds":172800}}]' \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v2.11/act_<AD_ACCOUNT_ID>/customaudiences
过去 2 天内搜索酒店时选择 checkin_date
至 checkout_date
入住时间段但未预订的用户:
use FacebookAds\Object\CustomAudience;
use FacebookAds\Object\Fields\CustomAudienceFields;
use FacebookAds\Object\Values\CustomAudienceSubtypeValues;
use FacebookAds\Object\Values\CustomAudienceClaimObjectiveValues;
use FacebookAds\Object\Values\CustomAudienceContentTypeValues;
$custom_audience = new CustomAudience(null, 'act_<AD_ACCOUNT_ID>');
$custom_audience->setData(array(
CustomAudienceFields::NAME => 'Travel Audience',
CustomAudienceFields::SUBTYPE => CustomAudienceSubtypeValues::CLAIM,
CustomAudienceFields::CLAIM_OBJECTIVE =>
CustomAudienceClaimObjectiveValues::TRAVEL,
CustomAudienceFields::CONTENT_TYPE => CustomAudienceContentTypeValues::HOTEL,
CustomAudienceFields::EVENT_SOURCE_GROUP => <EVENT_SOURCE_GROUP_ID>,
CustomAudienceFields::RULE => array(
'and' => array(
array(
'checkin_date' => array(
'gte' => (new \DateTime("+3 day"))->format('Y-m-d')
),
),
array(
'checkout_date' => array(
'lte' => (new \DateTime("+6 day"))->format('Y-m-d')
),
),
),
),
'inclusions' => array(
array(
'event' => 'Search',
'retention' => array('min_seconds'=> 0, 'max_seconds'=> 172800),
),
),
'exclusions' => array(
array(
'event' => 'Purchase',
'retention' => array('min_seconds'=> 0, 'max_seconds'=> 172800),
),
),
));
$custom_audience->create();
from facebookads.adobjects.customaudience import CustomAudience
import datetime
audience = CustomAudience(parent_id='act_<AD_ACCOUNT_ID>')
audience[CustomAudience.Field.name] = 'Travel Audience'
audience[CustomAudience.Field.subtype] = CustomAudience.Subtype.claim
audience[CustomAudience.Field.claim_objective] = \
CustomAudience.ClaimObjective.travel
audience[CustomAudience.Field.content_type] = CustomAudience.ContentType.hotel
audience[CustomAudience.Field.event_source_group] = <EVENT_SOURCE_GROUP_ID>
audience[CustomAudience.Field.rule] = {
'and': [
{
"checkin_date": {
"gte": str(datetime.date.today() + datetime.timedelta(days=3)),
},
},
{
"checkout_date": {
"gte": str(datetime.date.today() + datetime.timedelta(days=6)),
},
},
],
}
audience['inclusions'] = [
{
'event': 'Search',
'retention': {'min_seconds': 0, 'max_seconds': 172800},
},
]
audience['exclusions'] = [
{
'event': 'Purchase',
'retention': {'min_seconds': 0, 'max_seconds': 172800},
},
]
audience.remote_create()
curl \
-F 'name=Travel Audience' \
-F 'subtype=CLAIM' \
-F 'claim_objective=TRAVEL' \
-F 'content_type=HOTEL' \
-F 'event_source_group=<EVENT_SOURCE_GROUP_ID>' \
-F 'rule={
"and": [
{"checkin_date":{"gte":"2018-02-02"}},
{"checkout_date":{"lte":"2018-02-05"}}
]
}' \
-F 'inclusions=[{"event":"Search","retention":{"min_seconds":0,"max_seconds":172800}}]' \
-F 'exclusions=[{"event":"Purchase","retention":{"min_seconds":0,"max_seconds":172800}}]' \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v2.11/act_<AD_ACCOUNT_ID>/customaudiences
过去 2 天内搜索酒店时选择的入住时间段包含特殊日期(如圣诞节)但未预订的用户:
use FacebookAds\Object\CustomAudience;
use FacebookAds\Object\Fields\CustomAudienceFields;
use FacebookAds\Object\Values\CustomAudienceSubtypeValues;
use FacebookAds\Object\Values\CustomAudienceClaimObjectiveValues;
use FacebookAds\Object\Values\CustomAudienceContentTypeValues;
$custom_audience = new CustomAudience(null, 'act_<AD_ACCOUNT_ID>');
$custom_audience->setData(array(
CustomAudienceFields::NAME => 'Travel Audience',
CustomAudienceFields::SUBTYPE => CustomAudienceSubtypeValues::CLAIM,
CustomAudienceFields::CLAIM_OBJECTIVE =>
CustomAudienceClaimObjectiveValues::TRAVEL,
CustomAudienceFields::CONTENT_TYPE => CustomAudienceContentTypeValues::HOTEL,
CustomAudienceFields::EVENT_SOURCE_GROUP => <EVENT_SOURCE_GROUP_ID>,
CustomAudienceFields::RULE => array(
'itinerary_contains_date' => array(
'eq' => (new \DateTime())->setDate(Date('Y'), 12, 25)->format('Y-m-d')
),
),
'inclusions' => array(
array(
'event' => 'Search',
'retention' => array('min_seconds'=> 0, 'max_seconds'=> 172800),
),
),
'exclusions' => array(
array(
'event' => 'Purchase',
'retention' => array('min_seconds'=> 0, 'max_seconds'=> 172800),
),
),
));
$custom_audience->create();
from facebookads.adobjects.customaudience import CustomAudience
import datetime
audience = CustomAudience(parent_id='act_<AD_ACCOUNT_ID>')
audience[CustomAudience.Field.name] = 'Travel Audience'
audience[CustomAudience.Field.subtype] = CustomAudience.Subtype.claim
audience[CustomAudience.Field.claim_objective] = \
CustomAudience.ClaimObjective.travel
audience[CustomAudience.Field.content_type] = CustomAudience.ContentType.hotel
audience[CustomAudience.Field.event_source_group] = <EVENT_SOURCE_GROUP_ID>
audience[CustomAudience.Field.rule] = {
"itinerary_contains_date": {
"eq": str(datetime.date(datetime.date.today().year, 12, 25)),
},
}
audience['inclusions'] = [
{
'event': 'Search',
'retention': {'min_seconds': 0, 'max_seconds': 172800},
},
]
audience['exclusions'] = [
{
'event': 'Purchase',
'retention': {'min_seconds': 0, 'max_seconds': 172800},
},
]
audience.remote_create()
curl \
-F 'name=Travel Audience' \
-F 'subtype=CLAIM' \
-F 'claim_objective=TRAVEL' \
-F 'content_type=HOTEL' \
-F 'event_source_group=<EVENT_SOURCE_GROUP_ID>' \
-F 'rule={"itinerary_contains_date":{"eq":"2018-12-25"}}' \
-F 'inclusions=[{"event":"Search","retention":{"min_seconds":0,"max_seconds":172800}}]' \
-F 'exclusions=[{"event":"Purchase","retention":{"min_seconds":0,"max_seconds":172800}}]' \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v2.11/act_<AD_ACCOUNT_ID>/customaudiences
为单程航班创建受众的用户:
curl \ -F 'name=Travel Audience' \ -F 'claim_objective=TRAVEL' \ -F 'content_type=FLIGHT' \ -F 'event_source_group=<EVENT_SOURCE_GROUP_ID>' \ -F 'rule={"and":[{"returning_departure_date":{"exists":false]}}' \ -F 'inclusions=[ { "event": "Search", "count": {"gt":3}, "retention": {"min_seconds":0,"max_seconds":432000} } ]' \ -F 'exclusions=[{"event":"Purchase","retention":{"min_seconds":0,"max_seconds":172800}}]' \ -F 'access_token=<ACCESS_TOKEN>' \ https://graph.facebook.com/v2.11/act_<AD_ACCOUNT_ID>/customaudiences
受众创建完成后,您可以将他们添加到旅游类广告营销活动中的定位规范内。