Back to News for Developers

Dynamic Ads on Instagram

Today we are releasing Dynamic Ads on Instagram to all Facebook Marketing API developers.

To run Dynamic Ads on Instagram, you need to set up:

All of these steps are the same as creating Dynamic ads on Facebook except for the following differences:

  • Instagram Placement - Include instagramstream in the page_types field of your ad set.
  • Specify Instagram Account - Set instagram_actor_id field in the template creative, or the instagram_actor_id subfield of object_story_spec field in the template creative. This ID is the ID of the Instagram account ads will be delivered from. There are three ways to obtain an Instagram account ID: Business Manager owned Instagram account, Page connected Instagram account, and Page backed Instagram account.
  • No Access to the Post - Because each Instagram post is dynamically generated, you cannot get the instagram_permalink_url and instagram_story_id of the ad creative template. That means that you cannot get the likes and comments of your Dynamic Ad posts on Instagram.
  • Product Image - Usually this is the default image specified by image_url but it could be another image in additonal_image_urls if additional_image_index is set in the ad template creative. It must be at least 600 px or more in both width and height, not necessarily square though.
  • Text - The name (with Carousel format only) and message of a template_data are shown under the product image. The description is not. You should set the description if you are running the Dynamic Ads on both Facebook and Instagram together though.
  • Call To Action - The call_to_action of a template_data is optional. If it is not provided, a "LEARN MORE" button will be created by default, with the URL of the product shown.

The following code creates an ad creative for Dynamic Ads on Instagram with Carousel format.

use FacebookAds\Object\AdCreative;
use FacebookAds\Object\Fields\AdCreativeFields;
use FacebookAds\Object\Fields\ObjectStory\TemplateDataFields;
use FacebookAds\Object\Fields\ObjectStorySpecFields;
use FacebookAds\Object\ObjectStorySpec;
use FacebookAds\Object\ObjectStory\TemplateData;

$object_story_spec = new ObjectStorySpec();
ObjectStorySpecFields::PAGE_ID => <PAGE_ID>,
ObjectStorySpecFields::TEMPLATE_DATA => (new TemplateData())->setData(array(
TemplateDataFields::MESSAGE => 'Jasper\'s Market\'s latest produce. It\'s fun, easy, and most of all it\'s free!',
TemplateDataFields::LINK => '<LINK>',
TemplateDataFields::NAME => '{{}}',

$creative = new AdCreative(null, 'act_<AD_ACCOUNT_ID>');
AdCreativeFields::NAME => 'Dynamic Ad Template Creative Sample',
AdCreativeFields::OBJECT_STORY_SPEC => $object_story_spec,

from facebookads.adobjects.adcreative import AdCreative
from facebookads.adobjects.adcreativeobjectstoryspec \n    import AdCreativeObjectStorySpec

story = AdCreativeObjectStorySpec()
story[story.Field.page_id] = <PAGE_ID>
story[story.Field.instagram_actor_id] = <INSTAGRAM_ACCOUNT_ID>
story[story.Field.template_data] = {
'message': 'Jasper\'s Market\'s latest produce. It\'s fun, easy, and most of all it\'s free!',
'link': '<LINK>',
'name': '{{}}',

creative = AdCreative(parent_id='act_<AD_ACCOUNT_ID>')
creative[] = 'Dynamic Ad Template Creative Sample'
creative[AdCreative.Field.object_story_spec] = story
creative[AdCreative.Field.product_set_id] = <PRODUCT_SET_ID>
curl \
-F 'name=Dynamic Ad Template Creative Sample' \
-F 'object_story_spec={ 
"page_id": "<PAGE_ID>", 
"instagram_actor_id": "<INSTAGRAM_ACCOUNT_ID>", 
"template_data": { 
"link": "<LINK>", 
"message": "Jasper's Market's latest produce. It's fun, easy, and most of all it's free!", 
"name": "{{}}" 
}' \
-F 'product_set_id=<PRODUCT_SET_ID>' \
-F 'access_token=<ACCESS_TOKEN>' \<AD_ACCOUNT_ID>/adcreatives

Product Image Sizes

You should use product images of at least 600x600px for Instagram and for Facebook, for the best user experience. Facebook enforces product image size during Dynamic Ads delivery on Instagram.

If a product has an image that is too small for Instagram you will not see any errors when you create ads, but this product will not be delivered with Instagram Dynamic Ads.

For example, when a Dynamic Ad is served, Facebook decides to show product A, B, C, and D based on the user's activities. Product B's image is 400x650px and does not fulfill the 600x600px requirement. On Instagram, we show product A, C, D, and E instead, assuming E is the next relevant product with an image at least 600 x 600px.

We have created a sample script using our Python SDK to check the image sizes of the products of your product catalog. You can run the script online here, with a size limitation to avoid time-out. Or you can copy the code from there and run it on your own server without a size limit, if you want to check a large product catalog offline.