本指南假設您已為旅遊庫存建立目錄,並已於您的網站和/或流動應用程式內設定必要旅遊事件,且已為目錄與事件來源建立關聯。
由 2018 年 9 月 20 日起,對於 3.0 版之後的推廣 API,我們不會支援網站和應用程式自訂廣告受眾、互動自訂廣告受眾及從離線轉換數據所得之廣告受眾的 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
成功建立一種或多種廣告受眾後,您可以將其加至旅遊廣告宣傳活動的目標設定規格中。