ย้อนกลับไปที่ "ข่าวสำหรับผู้พัฒนา"

Expansion of Video Ads

Recently we've expanded the ability to use video creative to three (3) objectives: Page Likes, Local Awareness, and Website conversions. These objectives join the group of existing objectives that support video: Video Views, Page Post Engagement, Mobile App Install, Mobile App Engagement, Canvas App Install, and Canvas App Engagement.

Video Page Like Ads

Create a Page Like campaign:

use FacebookAds\Object\AdCampaign;
use FacebookAds\Object\Fields\AdCampaignFields;

$campaign = new AdCampaign(null, 'act_<AD_ACCOUNT_ID>');
$campaign->setData(array(
AdCampaignFields::NAME => 'my campaign group',
AdCampaignFields::STATUS => AdCampaign::STATUS_PAUSED,
AdCampaignFields::OBJECTIVE => AdObjectives::PAGE_LIKES,
));

$campaign->create();
from facebookads.objects import AdCampaign

campaign = AdCampaign(parent_id='act_<AD_ACCOUNT_ID>')

campaign[AdCampaign.Field.name] = 'my campaign group'
campaign[AdCampaign.Field.status] = AdCampaign.Status.paused
campaign[AdCampaign.Field.objective] = AdCampaign.Objective.page_likes

campaign.remote_create()
curl \
-F "name=my campaign" \
-F "campaign_group_status=PAUSED" \
-F "objective=PAGE_LIKES" \
-F "access_token=<ACCESS_TOKEN>" \
https://graph.facebook.com/<API_VERSION>/act_<AD_ACCOUNT_ID>/adcampaign_groups

Create an ad set promoting and optimizing for page likes:

use FacebookAds\Object\AdSet;
use FacebookAds\Object\Fields\AdSetFields;
use FacebookAds\Object\Values\BidTypes;

$adset = new AdSet(null, 'act_<AD_ACCOUNT_ID>');
$adset->setData(array(
AdSetFields::NAME => 'DailyBudgetSet',
AdSetFields::PROMOTED_OBJECT => array('page_id' => '<PAGE_ID>'),
AdSetFields::DAILY_BUDGET => 1000,
AdSetFields::BID_TYPE => BidTypes::BID_TYPE_ABSOLUTE_OCPM,
AdSetFields::BID_INFO => array(
'ACTIONS' => 150,
),
AdSetFields::TARGETING => array(
'geo_locations' => array(
'countries' => array('US'),
),
),
AdSetFields::CAMPAIGN_STATUS => AdSet::STATUS_ACTIVE,
AdSetFields::CAMPAIGN_GROUP_ID => <CAMPAIGN_ID>,
));

$adset->create();
from facebookads.objects import AdSet

adset = AdSet(parent_id='act_<AD_ACCOUNT_ID>')
adset[AdSet.Field.name] = 'DailyBudgetSet'
adset[AdSet.Field.promoted_object] = {'page_id': '<PAGE_ID>'}
adset[AdSet.Field.daily_budget] = 1000
adset[AdSet.Field.bid_type] = AdSet.BidType.absolute_ocpm
adset[AdSet.Field.bid_info] = {
'ACTIONS': 150,
}
adset[AdSet.Field.targeting] = {
'geo_locations': {
'countries': ['US'],
},
}
adset[AdSet.Field.status] = AdSet.Status.active
adset[AdSet.Field.campaign_group_id] = <CAMPAIGN_ID>

adset.remote_create()
curl \
-F "name=DailyBudgetSet" \
-F "promoted_object={'page_id': '<PAGE_ID>'}" \
-F "daily_budget=1000" \
-F "bid_type=ABSOLUTE_OCPM" \
-F "bid_info={'ACTIONS':150}" \
-F "targeting={'geo_locations': {'countries': ['US']}}" \
-F "campaign_status=ACTIVE" \
-F "campaign_group_id=<CAMPAIGN_ID>" \
-F "access_token=<ACCESS_TOKEN>" \
https://graph.facebook.com/act_<AD_ACCOUNT_ID>/adcampaigns

Create the video creative with a LIKE_PAGE call to action, available only through the /act_<AD_ACCOUNT_ID/adcreatives endpoint

use FacebookAds\Object\AdCreative;
use FacebookAds\Object\ObjectStory\VideoData;
use FacebookAds\Object\Fields\ObjectStory\VideoDataFields;
use FacebookAds\Object\ObjectStorySpec;
use FacebookAds\Object\Fields\ObjectStorySpecFields;
use FacebookAds\Object\Fields\AdCreativeFields;

$video_data = new VideoData();
$video_data->setData(array(
VideoDataFields::DESCRIPTION => 'try it out',
VideoDataFields::IMAGE_URL => '<IMAGE_URL>',
VideoDataFields::VIDEO_ID => '<VIDEO_ID>',
VideoDataFields::CALL_TO_ACTION => array(
'type' => 'LIKE_PAGE',
'value' => array(
'page' => '<PAGE_ID>',
)
),
));

$object_story_spec = new ObjectStorySpec();
$object_story_spec->setData(array(
ObjectStorySpecFields::PAGE_ID => <PAGE_ID>,
ObjectStorySpecFields::VIDEO_DATA => $video_data,
));

$creative = new AdCreative(null, 'act_<AD_ACCOUNT_ID>');

$creative->setData(array(
AdCreativeFields::NAME => 'Sample Creative',
AdCreativeFields::OBJECT_STORY_SPEC => $object_story_spec,
));

$creative->create();
from facebookads.objects import AdCreative
from facebookads.specs import ObjectStorySpec, VideoData

video_data = VideoData()
video_data[VideoData.Field.description] = 'try it out'
video_data[VideoData.Field.video_id] = '<VIDEO_ID>'
video_data[VideoData.Field.image_url] = '<IMAGE_URL>'

call_to_action = {
'type': 'LIKE_PAGE',
'value': {
'page': '<PAGE_ID>',
}
}

video_data[VideoData.Field.call_to_action] = call_to_action

object_story_spec = ObjectStorySpec()
object_story_spec[ObjectStorySpec.Field.page_id] = <PAGE_ID>
object_story_spec[ObjectStorySpec.Field.video_data] = video_data

creative = AdCreative(parent_id='act_<AD_ACCOUNT_ID>')
creative[AdCreative.Field.name] = 'AdCreative for Page Like Ad'
creative[AdCreative.Field.object_story_spec] = object_story_spec
creative.remote_create()
curl \
-F 'name=Video Page Like with CTA Creative' \
-F 'object_story_spec={"page_id":<PAGE_ID>, "video_data":{"call_to_action":{"type":"LIKE_PAGE", value:{"page":"<PAGE_ID>"}}, "video_id":"<VIDEO_ID>", "image_url":"<IMAGE_URL>", "description":"Video description"}}' \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/act_<AD_ACCOUNT_ID>/adcreatives

Assign the ad creative to an ad, and the ad to an ad set:

use FacebookAds\Object\AdGroup;
use FacebookAds\Object\Fields\AdGroupFields;

$ad = new AdGroup(null, 'act_<AD_ACCOUNT_ID>');
$ad->setData(array(
AdGroupFields::NAME => 'sample page post ad',
AdGroupFields::CAMPAIGN_ID => <AD_SET_ID>,
AdGroupFields::CREATIVE => array(
'creative_id' => <CREATIVE_ID>,
),
));

$ad->create();
from facebookads.objects import AdGroup

ad = AdGroup(parent_id='act_<AD_ACCOUNT_ID>')
ad[AdGroup.Field.name] = 'sample page post ad'
ad[AdGroup.Field.campaign_id] = <AD_SET_ID>
ad[AdGroup.Field.creative] = {'creative_id': '<CREATIVE_ID>'}

adgroup.remote_create()
curl \
-F "campaign_id=<AD_SET_ID>" \
-F "name=sample page post ad" \
-F "creative={'creative_id':<CREATIVE_ID>}" \
-F "access_token=<ACCESS_TOKEN>" \
https://graph.facebook.com/<API_VERSION>/act_<AD_ACCOUNT_ID>/adgroups

Local Awareness

Create a Local Awareness campaign:

use FacebookAds\Object\AdCampaign;
use FacebookAds\Object\Fields\AdCampaignFields;

$campaign  = new AdCampaign(null, 'act_<AD_ACCOUNT_ID>');
$campaign->setData(array(
AdCampaignFields::NAME => 'local awareness campaign',
AdCampaignFields::STATUS => AdCampaign::STATUS_PAUSED,
AdCampaignFields::OBJECTIVE => LOCAL_AWARENESS  
));

$campaign->create();
from facebookads.objects import AdCampaign

campaign = AdCampaign(parent_id='act_<AD_ACCOUNT_ID>')

campaign[AdCampaign.Field.name] = 'local awareness campaign'
campaign[AdCampaign.Field.status] = AdCampaign.Status.paused
campaign[AdCampaign.Field.objective] = AdCampaign.Objective.local_awareness

campaign.remote_create()
curl \ 
-F 'name=local awareness campaign' \  
-F 'campaign_group_status=PAUSED' \  
-F 'objective=LOCAL_AWARENESS' \  
-F 'access_token=<ACCESS_TOKEN>' \  
https://graph.facebook.com/<API_VERSION>/act_<AD_ACCOUNT_ID>/adcampaign_groups

Create an ad set with geotargeting. Here is an ad set creation example that targets people who live or are visiting the area 10 miles around 1601 Willow Road Menlo Park CA, and excludes the zip code 94040:

use FacebookAds\Object\AdSet;
use FacebookAds\Object\Fields\AdSetFields;
use FacebookAds\Object\Values\BidTypes;

$adset = new AdSet(null, 'act_<AD_ACCOUNT_ID>');
$adset->setData(array(
AdSetFields::NAME => 'local awareness with daily budget',
AdSetFields::DAILY_BUDGET => 1000,
AdSetFields::CAMPAIGN_STATUS => AdSet::STATUS_PAUSED,
AdSetFields::CAMPAIGN_GROUP_ID => <CAMPAIGN_ID>,
AdSetFields::BID_TYPE => BidTypes::BID_TYPE_ABSOLUTE_OCPM,
AdSetFields::BID_INFO => array(
'REACH' => 300,
),
AdSetFields::TARGETING => array(
'geo_locations' => array(
'custom_locations' => array(
array(
'latitude' => 37.48327,
'longitude' => -122.15033,
'radius' => 10,
'distance_unit' => 'mile',
'address_string' => '1601 Willow Road, Menlo Park, CA 94025',
),
),
'location_types' => array(
'home',
'recent',
),
),
'excluded_geo_locations' => array(
'zips' => array(
array(
'key' => 'US:94040',
),
),
),
),
));

$adset->create();
from facebookads.objects import AdSet

adset = AdSet(parent_id='act_<AD_ACCOUNT_ID>')
adset[AdSet.Field.name] = 'local awareness with daily budget'
adset[AdSet.Field.daily_budget] = 1000
adset[AdSet.Field.status] = AdSet.Status.paused
adset[AdSet.Field.campaign_group_id] = <CAMPAIGN_ID>
adset[AdSet.Field.bid_type] = AdSet.BidType.absolute_ocpm
adset[AdSet.Field.bid_info] = {
'REACH': 300,
}
adset[AdSet.Field.targeting] = {
'geo_locations': {
'custom_locations': [
{
'latitude': 37.48327,
'longitude': -122.15033,
'radius': 10,
'distance_unit': 'mile',
'address_string': '1601 Willow Road, Menlo Park, CA 94025',
},
],
'location_type': ['home', 'recent'],
},
'excluded_geo_locations': {
'zips': [
{'key': 'US:94040'},
]
}
}

adset.remote_create()
curl \
-F "name=local awareness with daily budget" \
-F "daily_budget=1000" \
-F "campaign_status=PAUSED" \
-F "campaign_group_id=<CAMPAIGN_ID>" \
-F "bid_type=ABSOLUTE_OCPM" \
-F "bid_info={'REACH':300}" \
-F "targeting={'geo_locations':{'custom_locations' : [{'latitude': 37.48327, 'longitude': -122.15033, 'radius': 10, 'distance_unit': 'mile', 'address_string': '1601 Willow Road, Menlo Park, CA 94025'}],'location_types':['home', 'recent']}, 'excluded_geo_locations':{'zips':[{'key':'US:94040'}]}}" \  
-F "access_token=<ACCESS_TOKEN>" \
https://graph.facebook.com/<API_VERSION>/act_<AD_ACCOUNT_ID>/adcampaigns

Create the video creative with a GET_DIRECTIONS call to action:

use FacebookAds\Object\AdCreative;
use FacebookAds\Object\ObjectStory\VideoData;
use FacebookAds\Object\Fields\ObjectStory\VideoDataFields;
use FacebookAds\Object\ObjectStorySpec;
use FacebookAds\Object\Fields\ObjectStorySpecFields;
use FacebookAds\Object\Fields\AdCreativeFields;

$video_data = new VideoData();
$video_data->setData(array(
VideoDataFields::DESCRIPTION => 'Come check out our new store in Menlo Park!',
VideoDataFields::IMAGE_URL => '<IMAGE_URL>',
VideoDataFields::VIDEO_ID => '<VIDEO_ID>',
VideoDataFields::CALL_TO_ACTION => array(
'type' => 'GET_DIRECTIONS',
'value' => array(
'link' => 'fbgeo://37.48327, -122.15033, "1601 Willow Rd Menlo Park CA"',
)
),
));

$object_story_spec = new ObjectStorySpec();
$object_story_spec->setData(array(
ObjectStorySpecFields::PAGE_ID => <PAGE_ID>,
ObjectStorySpecFields::VIDEO_DATA => $video_data,
));

$creative = new AdCreative(null, 'act_<AD_ACCOUNT_ID>');

$creative->setData(array(
AdCreativeFields::NAME => 'Video Local Awareness Creative',
AdCreativeFields::OBJECT_STORY_SPEC => $object_story_spec,
));

$creative->create();
from facebookads.objects import AdCreative
from facebookads.specs import ObjectStorySpec, VideoData

video_data = VideoData()
video_data[VideoData.Field.description] = 'Come check out our new store in Menlo Park!'
video_data[VideoData.Field.video_id] = '<VIDEO_ID>'
video_data[VideoData.Field.image_url] = '<IMAGE_URL>'

call_to_action = {
'type': 'GET_DIRECTIONS',
'value': {
'link': 'fbgeo://37.48327, -122.15033, "1601 Willow Rd Menlo Park CA"',
}
}

video_data[VideoData.Field.call_to_action] = call_to_action

object_story_spec = ObjectStorySpec()
object_story_spec[ObjectStorySpec.Field.page_id] = <PAGE_ID>
object_story_spec[ObjectStorySpec.Field.video_data] = video_data

creative = AdCreative(parent_id='act_<AD_ACCOUNT_ID>')
creative[AdCreative.Field.name] = 'Video Local Awareness Creative'
creative[AdCreative.Field.object_story_spec] = object_story_spec
creative.remote_create()
curl \
-F 'name=Video Local Awareness Creative' \
-F 'object_story_spec={"page_id": "<PAGE_ID>", "video_data": {"image_url": "<IMAGE_URL>", "video_id": "<VIDEO_ID>", "description": "Come check out our new store in Menlo Park!", "call_to_action": {"type": "GET_DIRECTIONS", "value":{"link":"fbgeo://37.48327, -122.15033, "1601 Willow Rd Menlo Park CA""}}}}' \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/act_<AD_ACCOUNT_ID>/adcreatives

Assign the ad creative to an ad, and the ad to an ad set:

use FacebookAds\Object\AdGroup;
use FacebookAds\Object\Fields\AdGroupFields;

$ad = new AdGroup(null, 'act_<AD_ACCOUNT_ID>');
$ad->setData(array(
AdGroupFields::NAME => 'sample page post ad',
AdGroupFields::CAMPAIGN_ID => <AD_SET_ID>,
AdGroupFields::CREATIVE => array(
'creative_id' => <CREATIVE_ID>,
),
));

$ad->create();
from facebookads.objects import AdGroup

ad = AdGroup(parent_id='act_<AD_ACCOUNT_ID>')
ad[AdGroup.Field.name] = 'sample page post ad'
ad[AdGroup.Field.campaign_id] = <AD_SET_ID>
ad[AdGroup.Field.creative] = {'creative_id': '<CREATIVE_ID>'}

adgroup.remote_create()
curl \
-F "campaign_id=<AD_SET_ID>" \
-F "name=sample page post ad" \
-F "creative={'creative_id':<CREATIVE_ID>}" \
-F "access_token=<ACCESS_TOKEN>" \
https://graph.facebook.com/<API_VERSION>/act_<AD_ACCOUNT_ID>/adgroups

Website Conversions

Create a Website Conversions campaign:

use FacebookAds\Object\AdCampaign;
use FacebookAds\Object\Fields\AdCampaignFields;

$campaign = new AdCampaign(null, 'act_<AD_ACCOUNT_ID>');
$campaign->setData(array(
AdCampaignFields::NAME => 'my campaign group',
AdCampaignFields::STATUS => AdCampaign::STATUS_PAUSED,
AdCampaignFields::OBJECTIVE => AdObjectives::WEBSITE_CONVERSIONS,
));

$campaign->create();
from facebookads.objects import AdCampaign

campaign = AdCampaign(parent_id='act_<AD_ACCOUNT_ID>')

campaign[AdCampaign.Field.name] = 'my campaign group'
campaign[AdCampaign.Field.status] = AdCampaign.Status.paused
campaign[AdCampaign.Field.objective] = AdCampaign.Objective.website_conversions

campaign.remote_create()
curl \
-F "name=my campaign" \
-F "campaign_group_status=PAUSED" \
-F "objective=WEBSITE_CONVERSIONS" \
-F "access_token=<ACCESS_TOKEN>" \
https://graph.facebook.com/<API_VERSION>/act_<AD_ACCOUNT_ID>/adcampaign_groups

Create an ad set promoting and optimizing for the conversion pixel:

use FacebookAds\Object\AdSet;
use FacebookAds\Object\Fields\AdSetFields;
use FacebookAds\Object\Values\BidTypes;

$adset = new AdSet(null, 'act_<AD_ACCOUNT_ID>');
$adset->setData(array(
AdSetFields::NAME => 'DailyBudgetSet',
AdSetFields::PROMOTED_OBJECT => array('pixel_id' => '<PIXEL_ID>'),
AdSetFields::DAILY_BUDGET => 1000,
AdSetFields::BID_TYPE => BidTypes::BID_TYPE_ABSOLUTE_OCPM,
AdSetFields::BID_INFO => array(
'ACTIONS' => 150,
),
AdSetFields::TARGETING => array(
'geo_locations' => array(
'countries' => array('US'),
),
),
AdSetFields::CAMPAIGN_STATUS => AdSet::STATUS_ACTIVE,
AdSetFields::CAMPAIGN_GROUP_ID => <CAMPAIGN_ID>,
));

$adset->create();
from facebookads.objects import AdSet

adset = AdSet(parent_id='act_<AD_ACCOUNT_ID>')
adset[AdSet.Field.name] = 'DailyBudgetSet'
adset[AdSet.Field.promoted_object] = {'pixel_id': '<PIXEL_ID>'}
adset[AdSet.Field.daily_budget] = 1000
adset[AdSet.Field.bid_type] = AdSet.BidType.absolute_ocpm
adset[AdSet.Field.bid_info] = {'ACTIONS': 150}
adset[AdSet.Field.targeting] = {
'geo_locations': {
'countries': ['US'],
},
}
adset[AdSet.Field.status] = AdSet.Status.active
adset[AdSet.Field.campaign_group_id] = <CAMPAIGN_ID>

adset.remote_create()
curl \
-F "name=DailyBudgetSet" \
-F "promoted_object={'pixel_id': '<PIXEL_ID>'}" \
-F "daily_budget=1000" \
-F "bid_type=ABSOLUTE_OCPM" \
-F "bid_info={'ACTIONS':150}" \
-F "targeting={'geo_locations': {'countries': ['US']}}" \
-F "campaign_status=ACTIVE" \
-F "campaign_group_id=<CAMPAIGN_ID>" \
-F "access_token=<ACCESS_TOKEN>" \
https://graph.facebook.com/act_<AD_ACCOUNT_ID>/adcampaigns

Create the video creative with any call to action

use FacebookAds\Object\AdCreative;
use FacebookAds\Object\ObjectStory\VideoData;
use FacebookAds\Object\Fields\ObjectStory\VideoDataFields;
use FacebookAds\Object\ObjectStorySpec;
use FacebookAds\Object\Fields\ObjectStorySpecFields;
use FacebookAds\Object\Fields\AdCreativeFields;

$video_data = new VideoData();
$video_data->setData(array(
VideoDataFields::DESCRIPTION => 'try it out',
VideoDataFields::IMAGE_URL => '<IMAGE_URL>',
VideoDataFields::VIDEO_ID => '<VIDEO_ID>',
VideoDataFields::CALL_TO_ACTION => array(
'type' => 'SHOP_NOW',
'value' => array(
'link' => '<LINK>',
)
),
));

$object_story_spec = new ObjectStorySpec();
$object_story_spec->setData(array(
ObjectStorySpecFields::PAGE_ID => <PAGE_ID>,
ObjectStorySpecFields::VIDEO_DATA => $video_data,
));

$creative = new AdCreative(null, 'act_<AD_ACCOUNT_ID>');

$creative->setData(array(
AdCreativeFields::NAME => 'AdCreative for Website Conversions Ad',
AdCreativeFields::OBJECT_STORY_SPEC => $object_story_spec,
));

$creative->create();
from facebookads.objects import AdCreative
from facebookads.specs import ObjectStorySpec, VideoData

video_data = VideoData()
video_data[VideoData.Field.description] = 'try it out'
video_data[VideoData.Field.video_id] = '<VIDEO_ID>'
video_data[VideoData.Field.image_url] = '<IMAGE_URL>'

call_to_action = {
'type': 'SHOP_NOW',
'value': {
'link': '<LINK>',
}
}

video_data[VideoData.Field.call_to_action] = call_to_action

object_story_spec = ObjectStorySpec()
object_story_spec[ObjectStorySpec.Field.page_id] = <PAGE_ID>
object_story_spec[ObjectStorySpec.Field.video_data] = video_data

creative = AdCreative(parent_id='act_<AD_ACCOUNT_ID>')
creative[AdCreative.Field.name] = 'AdCreative for Website Conversions Ad'
creative[AdCreative.Field.object_story_spec] = object_story_spec
creative.remote_create()
curl \
-F 'name=AdCreative for Website Conversions Ad' \
-F 'object_story_spec={"page_id":<PAGE_ID>, "video_data":{"call_to_action":{"type":"SHOP_NOW", value:{"link":"<LINK>"}}, "video_id":"<VIDEO_ID>", "image_url":"<IMAGE_URL>", "description":"Video description"}}' \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/act_<AD_ACCOUNT_ID>/adcreatives

Assign the ad creative to an ad, and the ad to an ad set:

use FacebookAds\Object\AdGroup;
use FacebookAds\Object\Fields\AdGroupFields;

$ad = new AdGroup(null, 'act_<AD_ACCOUNT_ID>');
$ad->setData(array(
AdGroupFields::NAME => 'sample page post ad',
AdGroupFields::CAMPAIGN_ID => <AD_SET_ID>,
AdGroupFields::CREATIVE => array(
'creative_id' => <CREATIVE_ID>,
),
));

$ad->create();
from facebookads.objects import AdGroup

ad = AdGroup(parent_id='act_<AD_ACCOUNT_ID>')
ad[AdGroup.Field.name] = 'sample page post ad'
ad[AdGroup.Field.campaign_id] = <AD_SET_ID>
ad[AdGroup.Field.creative] = {'creative_id': '<CREATIVE_ID>'}

adgroup.remote_create()
curl \
-F "campaign_id=<AD_SET_ID>" \
-F "name=sample page post ad" \
-F "creative={'creative_id':<CREATIVE_ID>}" \
-F "access_token=<ACCESS_TOKEN>" \
https://graph.facebook.com/<API_VERSION>/act_<AD_ACCOUNT_ID>/adgroups


แท็ก: