這份指南會假設您已備妥內含旅遊庫存資料的目錄,並已在網站和/或行動應用程式設定必要的旅遊事件,且已將目錄連結至事件來源。
自 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
此時,您應該已設定好使用者訊號(也就是像素和/或應用程式事件),並已建立事件來源群組和旅遊目錄的關聯。
若要鎖定已經明確顯示旅遊意願的用戶,您必須建立想要對其供應廣告的用戶動態旅遊廣告受眾。您可以根據用戶的旅遊意願訊號,將用戶納入或排除。除了與網站自訂廣告受眾相關的事件外,您也可以套用額外的規則式篩選條件。建立動態航班廣告受眾時,必須指定 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
廣告受眾一旦建立後,便可新增至旅遊廣告行銷活動中的目標設定規格。