旅遊廣告:廣告受眾管理

本指南假設您已為旅遊庫存建立目錄,並已於您的網站和/或流動應用程式內設定必要旅遊事件,且已為目錄與事件來源建立關聯。

由 2018 年 9 月 20 日起,對於 3.0 版之後的推廣 API,我們不會支援網站和應用程式自訂廣告受眾、互動自訂廣告受眾及從離線轉換數據所得之廣告受眾的 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:建立旅遊廣告受眾

此時,您應該已設定用戶訊號(即像素和/或應用程式事件),並已將其與事件來源群組和您的一個或多個旅遊目錄建立關聯。

如需鎖定表露明確旅遊意願的用戶,則您必須建立動態旅遊廣告受眾作為您廣告的刊登對象。您可以根據用戶的旅遊意願訊號,將用戶納入或排除於受眾之中。除事件以外,您還可以按照網站自訂廣告受眾之類的處理方式,套用其他以規則為主的篩選條件。對於動態航班廣告受眾,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 欄位則會是像素、應用程式或 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

當至少有一個 content_id 存在於指定的 hotel_set_id 時,只配對相關事件。

僅限已將 content_type 設為 HOTEL 的旅遊廣告受眾。

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

destination_set_id

類型:int

當至少有一個 content_id 存在於指定的 destination_set_id 時,只配對那些事件。

僅限已將 content_type 設為 DESTINATION 的旅遊廣告受眾。

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

flight_set_id

類型:int

此為航班廣告的必要項目。

當航線(從 origin_airport 飛往 destination_airport)存在於指定的 flight_set_id 時,只配對那些事件。

僅限已將 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

旅客總人數

  • 若是 hoteldestinationcontent_type,計算方式為 num_adults + num_children
  • 若是 flightcontent_typenum_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

成功建立一種或多種廣告受眾後,您可以將其加至旅遊廣告宣傳活動的目標設定規格中。