旅游广告 — 受众管理

本指南假定您拥有旅游库存目录,且已经为网站或移动应用设置了所需的旅游事件,同时已经关联目录和事件源。

自 2018 年 9 月 20 日起,对于市场营销 API 3.0 之后的版本,我们将不再为网站和应用的自定义受众、互动自定义受众以及线下转化数据受众提供 subtype 支持。唯一的例外是视频的互动自定义受众,我们仍将为其提供 subtype 支持。

两步创建旅游受众:

第 1 步:创建和分享旅游事件源组

除了关联目录和事件源,您还必须创建事件源组。事件源组将用于填充受众。

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

第 2 步:创建旅游受众

此时,您应该已设置用户信号(即,Pixel 像素代码事件和/或应用事件)并将其与事件源组和您的旅游目录相关联。

如要定位已表现出明确旅游意向的用户,您必须创建一组动态旅游受众,以便向其投放广告。您可以根据用户的旅游意向信号来添加和排除用户。除事件以外,您还可以应用其他基于规则的筛选条件,例如“网站自定义受众”。对于动态航班受众,flight_set_id 字段是必要项。对于酒店和目的地受众,您无需指定 hotel_set_iddestination_set_id

如要设置新的旅游受众,请向 /act_<AD_ACCOUNT_ID>/customaudiences 发出 HTTP POST

受众参数

字段名称和类型描述

claim_objective

类型:enum {TRAVEL}

必要

受众的目标。

必须设置为 TRAVEL

content_type

类型:enum {HOTEL, FLIGHT, DESTINATION}

必要

指定用于构建此受众的信号类型。

必须设置为 HOTELFLIGHTDESTINATION

event_sources

类型:json string

包含 idtype 对的 JSON 数组。id 字段提供的是单个事件源编号,type 字段则可以是 Pixel 像素代码、应用或 offline_events。例如:

"event_sources": [
 {
 "type": "pixel",
 "id": "562030684179932"
 },
 {
 "type": "app",
 "id": "562030684179934"
 }
] 

如果未提供 event_source_group,则此为必要字段。如果提供此字段,请不要同时提供 event_source_group

event_source_group

类型:id

指定其事件将支持受众的事件源组。如果未提供 event_sources,则必需提供此字段。

inclusions

类型:object[]

必要

JSON 对象数组,列出可让帐户管理中心帐户有资格成为相关受众的所有意向信号。请参阅下文的添加对象参数表格。

description

类型:string

对受众的进一步描述。

exclusions

类型:object[]

JSON 对象数组,列出将符合条件的帐户管理中心帐户从相关受众中排除的所有意向信号。请参阅下文的排除对象参数表格。

rule

类型:object

在处理任何 inclusionsexclusions 之前,应用于事件流的典型受众规则。使用任何典型参数,并参阅下文的规则对象旅游参数表格,了解适用于旅游广告的特定参数。

添加对象参数

字段名称和类型描述

event

类型:enum {Search, ViewContent, InitiateCheckout, Purchase}

必要

您想要添加的信号的事件名称。

示例:{"event": "Search", …}

retention

类型:object

必要

自从接收事件后,将其用作添加用户到受众范围的依据的最短/最长时间。留存期限必须至少为 4 个小时。

请参阅下文的留存对象参数表格。

示例:{…, "retention": {"min_seconds": 0, "max_seconds": 259200}, …}

booking_window

类型:object

预订时段指用户入住日期与当前日期之间的时间(以秒为单位)。您指定时间范围后,系统仅会将预订时段在此范围内的用户添加为受众。此外,我们也支持预订时段为负数,让您能将入住日期在过去的用户添加为受众。

请参阅下文的预订时段对象参数表格。

示例:

  • {"booking_window": {"min_seconds": 0, "max_seconds": 259200}}
  • {"booking_window": {"max_seconds": 0}}

count

类型:JSON 运算符

事件被触发的次数。您可以在此处使用等式运算符和数值比较运算符。

示例:{…"count": {"lte": 3}, …}

留存对象参数

字段名称和类型描述

max_seconds

类型:int

必要

自从接收事件起的最长时间(以秒为单位)。

示例:259200

min_seconds

类型:int

自从接收事件起的最短时间(以秒为单位)。

示例:0

预订时段对象参数

字段名称和类型描述

min_seconds

类型:int

必要

当前日期和用户预期入住日期之间的最短时间(以秒为单位)。

示例:172800

max_seconds

类型:int

必要

当前日期和用户预期入住日期之间的最长时间(以秒为单位)。

示例:604800

排除对象参数

字段名称和类型描述

event

类型:enum { Search, ViewContent, InitiateCheckout, Purchase }

必要

与您想要排除的信号相关的事件名称。

示例:{"event": "Search", …}

retention

类型:object

必要

自从接收事件后,将其用作从受众范围排除用户的依据的最短/最长时间。留存期限必须至少为 4 个小时。

请参阅下文的留存对象参数表格。

示例:{…, "retention": {"min_seconds": 0, "max_seconds": 259200}, …}

规则对象旅游参数

与典型参数一样,每一个旅游参数都可与任何标准的 JSON运算符一起使用。

字段名称和类型描述

hotel_set_id

类型:int

当指定的 hotel_set_id 中至少有一个 content_id 时,才会匹配事件。

仅适用于 content_type 设置为 HOTEL 的旅游受众。

示例:{…, "hotel_set_id": {"eq": 123456789}, …}

destination_set_id

类型:int

仅匹配在指定的 destination_set_id 中至少有一个 content_id 的事件。

仅适用于 content_type 设置为 DESTINATION 的旅游受众。

示例:{…, "destination_set_id": {"eq": 123456789}, …}

flight_set_id

类型:int

对于航班广告为必要项。

仅匹配指定的 flight_set_id 中存在(从 origin_airport 出发前往 destination_airport 的)航线的事件。

仅适用于 content_type 设置为 FLIGHT 的旅游受众。

示例:{…, "flight_set_id": {"eq": 123456789}, …}

length_of_stay

类型:int

旅行期间的入住晚数。

示例:{… "length_of_stay": {"eq": 1}, …}

number_of_weekends

类型:int

自开始至结束日期之间的周末数

示例:{…, "number_of_weekends": {"gte": 5}, …}

num_travelers

类型:int

旅客总人数

  • 对于 hoteldestination 类型的 content_type,此字段为 num_adults + num_children
  • 对于 flight 类型的 content_type,此字段还包括 num_infants

示例:{…, "num_travelers": {"gt": 1}, …}

日期字段:

酒店广告

  • checkin_date
  • checkout_date

航班广告

  • departing_departure_date
  • departing_arrival_date
  • returning_departure_date
  • returning_arrival_date

目的地广告

  • travel_start
  • travel_end

类型:string

根据 content_type 使用相关的日期字段。

示例:{"checkin_date": {"gte": "2016-09-01"}}

itinerary_contains_date

类型:string

旅行包含具体日期。

示例:{"itinerary_contains_date": {"eq": "2016-12-25"}}

代码示例

过去 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_datecheckout_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

受众创建完成后,您可以将他们添加到旅游类广告营销活动中的定位规范内。