Back to News for Developers

Video Creative in the Carousel Format

October 21, 2015ByRyan Kanoknukulchai

Last year, we introduced carousel ads which allowed advertisers to showcase multiple static images within a single ad unit. The carousel format is a popular ad format that provides advertisers with more creative real-estate in News Feed.

With the latest update, we are adding the video creative to the carousel unit, giving advertisers the creative flexibility to leverage the most engaging and powerful format we have in feed. Adding video as a creative option can bring sight, sound, and motion to help advertisers improve both their Brand and DR objectives.

Advertisers can use video as a creative option in any slot of the carousel unit to pull people into the unit and will be available for Mobile App Install, Mobile App Engagement, Website Clicks, Website Conversions, and Page Post Engagement objectives. Developers can simply provide the video id of a previously uploaded video in the video_id field within the child_attachments in any order to add videos along side photo-only children.

Here is an example of carousel ads using video creatives. Note that when video_id is used, image_hash or picture must also be specified.

use FacebookAds\Object\AdCreative;
use FacebookAds\Object\Fields\AdCreativeFields;
use FacebookAds\Object\Fields\ObjectStory\LinkDataFields;
use FacebookAds\Object\Fields\ObjectStorySpecFields;
use FacebookAds\Object\Fields\ObjectStory\AttachmentDataFields;
use FacebookAds\Object\ObjectStory\AttachmentData;
use FacebookAds\Object\ObjectStory\LinkData;
use FacebookAds\Object\ObjectStorySpec;

$product1 = new AttachmentData();
$product1->setData(array(
AttachmentDataFields::LINK => '<PRODUCT_1_URL>',
AttachmentDataFields::NAME => 'Product 1',
AttachmentDataFields::DESCRIPTION => '$8.99',
AttachmentDataFields::IMAGE_HASH => '<IMAGE_1_HASH>',
AttachmentDataFields::VIDEO_ID => '<VIDEO_1_ID>',
));

$product2 = new AttachmentData();
$product2->setData(array(
AttachmentDataFields::LINK => '<PRODUCT_2_URL>',
AttachmentDataFields::NAME => 'Product 2',
AttachmentDataFields::DESCRIPTION => '$9.99',
AttachmentDataFields::IMAGE_HASH => '<IMAGE_2_HASH>',
AttachmentDataFields::VIDEO_ID => '<VIDEO_2_ID>',
));

$product3 = new AttachmentData();
$product3->setData(array(
AttachmentDataFields::LINK => '<PRODUCT_3_URL>',
AttachmentDataFields::NAME => 'Product 3',
AttachmentDataFields::DESCRIPTION => '$10.99',
AttachmentDataFields::IMAGE_HASH => '<IMAGE_3_HASH>',
));

$product4 = new AttachmentData();
$product4->setData(array(
AttachmentDataFields::LINK => '<PRODUCT_4_URL>',
AttachmentDataFields::NAME => 'Product 4',
AttachmentDataFields::DESCRIPTION => '$11.99',
AttachmentDataFields::IMAGE_HASH => '<IMAGE_4_HASH>',
));

$link_data = new LinkData();
$link_data->setData(array(
LinkDataFields::LINK => '<URL>',
LinkDataFields::CAPTION => 'My caption',
LinkDataFields::CHILD_ATTACHMENTS => array($product1, $product2, $product3, $product4),
));

$object_story_spec = new ObjectStorySpec();
$object_story_spec->setData(array(
ObjectStorySpecFields::PAGE_ID => <PAGE_ID>,
ObjectStorySpecFields::LINK_DATA => $link_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, LinkData, AttachmentData

product1 = AttachmentData()
product1[AttachmentData.Field.link] = '<PRODUCT_1_URL>'
product1[AttachmentData.Field.name] = 'Product 1'
product1[AttachmentData.Field.description] = '$8.99'
product1[AttachmentData.Field.image_hash] = '<IMAGE_1_HASH>'
product1[AttachmentData.Field.video_id] = '<VIDEO_1_ID>'

product2 = AttachmentData()
product2[AttachmentData.Field.link] = '<PRODUCT_2_URL>'
product2[AttachmentData.Field.name] = 'Product 2'
product2[AttachmentData.Field.description] = '$9.99'
product2[AttachmentData.Field.image_hash] = '<IMAGE_2_HASH>'
product2[AttachmentData.Field.video_id] = '<VIDEO_2_ID>'

product3 = AttachmentData()
product3[AttachmentData.Field.link] = '<PRODUCT_3_URL>'
product3[AttachmentData.Field.name] = 'Product 3'
product3[AttachmentData.Field.description] = '$10.99'
product3[AttachmentData.Field.image_hash] = '<IMAGE_3_HASH>'

product4 = AttachmentData()
product4[AttachmentData.Field.link] = '<PRODUCT_4_URL>'
product4[AttachmentData.Field.name] = 'Product 4'
product4[AttachmentData.Field.description] = '$11.99'
product4[AttachmentData.Field.image_hash] = '<IMAGE_4_HASH>'

link = LinkData()
link[link.Field.link] = '<URL>'
link[link.Field.child_attachments] = [product1, product2, product3, product4]
link[link.Field.caption] = 'My caption'

story = ObjectStorySpec()
story[story.Field.page_id] = <PAGE_ID>
story[story.Field.link_data] = link

creative = AdCreative(parent_id='act_<AD_ACCOUNT_ID>')
creative[AdCreative.Field.name] = 'Sample Creative'
creative[AdCreative.Field.object_story_spec] = story
creative.remote_create()
print(creative)
curl \
-F "name=Sample Creative" \
-F "object_story_spec={\
'page_id':<PAGE_ID>, \
'link_data':{ \
'message':'Try it out', \
'link':'<URL>', \
'caption':'My caption', \
'multi_share_optimized':true, \
'child_attachments':[ \
{'link':'<PRODUCT_1_URL>','name':'product 1','description':'$8.99', 'image_hash':'<IMAGE_1_HASH>','video_id':'<VIDEO_1_ID>'}, \
{'link':'<PRODUCT_2_URL>','name':'product 2','description':'$9.99', 'image_hash':'<IMAGE_2_HASH>','video_id':'<VIDEO_2_ID>'}, \
{'link':'<PRODUCT_3_URL>','name':'product 3','description':'$10.99','image_hash':'<IMAGE_3_HASH>'}, \
{'link':'<PRODUCT_4_URL>','name':'product 4','description':'$11.99','image_hash':'<IMAGE_4_HASH>'}\
]}}" \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/<API_VERSION>/act_<ADACCOUNT_ID>/adcreatives

For more details on the API, refer to the Carousel Ads and Ad Video reference documents.


Tags: