For Instagram Ads, you can get a preview of:
You can use format options with an ad or ad creative ID to preview an existing ad. For ad_format
, you have:
Format | Description |
---|---|
| Instagram Explore Feed format. Learn more about ads in Instagram Explore. |
| Instagram Explore Video format. Learn more about ads in Instagram Explore. |
| Instagram Reels placement. |
| Instagram feed post format. |
| Instagram story format. |
The ad preview call looks like this:
use FacebookAds\Object\Ad;
use FacebookAds\Object\Values\AdPreviewAdFormatValues;
$adgroup = new Ad(<AD_ID>);
$preview = $adgroup->getPreviews(array(), array(
'ad_format' => AdPreviewAdFormatValues::INSTAGRAM_STANDARD,
))->current();
from facebookads.adobjects.ad import Ad
from facebookads.adobjects.adpreview import AdPreview
ad = Ad(<AD_ID>)
ad.get_previews(params={
'ad_format': AdPreview.AdFormat.instagram_standard,
})
curl -G \
-d 'ad_format=INSTAGRAM_STANDARD' \
-d 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v2.11/<AD_ID>/previews
To preview an ad before providing ad creative, pass the creative's object_story_spec
in the preview's creative
parameter. You must provide instagram_actor_id
and page_id
for both Instagram only placement and mixed placement ads:
use FacebookAds\Object\AdAccount;
use FacebookAds\Object\AdCreative;
use FacebookAds\Object\AdCreativeLinkData;
use FacebookAds\Object\Values\AdCreativeCallToActionTypeValues;
use FacebookAds\Object\Fields\AdCreativeFields;
use FacebookAds\Object\Fields\AdCreativeLinkDataFields;
use FacebookAds\Object\Fields\AdCreativeObjectStorySpecFields;
use FacebookAds\Object\Fields\AdPreviewFields;
use FacebookAds\Object\AdCreativeObjectStorySpec;
use FacebookAds\Object\Values\AdPreviewAdFormatValues;
$creative = new AdCreative();
$creative->setData(array(
AdCreativeFields::OBJECT_STORY_SPEC =>
(new AdCreativeObjectStorySpec())->setData(array(
AdCreativeObjectStorySpecFields::PAGE_ID => <PAGE_ID>,
AdCreativeObjectStorySpecFields::INSTAGRAM_ACTOR_ID =>
<INSTAGRAM_ACTOR_ID>,
AdCreativeObjectStorySpecFields::LINK_DATA =>
(new AdCreativeLinkData())->setData(array(
AdCreativeLinkDataFields::IMAGE_HASH => '<IMAGE_HASH>',
AdCreativeLinkDataFields::MESSAGE => 'Ad Message',
AdCreativeLinkDataFields::CAPTION => 'www.example.com',
AdCreativeLinkDataFields::LINK => '<URL>',
AdCreativeLinkDataFields::CALL_TO_ACTION => array(
'type' => AdCreativeCallToActionTypeValues::LEARN_MORE,
'value' => array(
'link' => '<URL>',
),
),
)),
)),
));
$account = new AdAccount('act_<AD_ACCOUNT_ID>');
$preview = $account->getGeneratePreviews(array(), array(
AdPreviewFields::CREATIVE => $creative,
AdPreviewFields::AD_FORMAT => AdPreviewAdFormatValues::INSTAGRAM_STANDARD,
))->current();
from facebookads.adobjects.adaccount import AdAccount
from facebookads.adobjects.adcreative import AdCreative
from facebookads.adobjects.adcreativelinkdatacalltoaction \
import AdCreativeLinkDataCallToAction
from facebookads.adobjects.adcreativelinkdata import AdCreativeLinkData
from facebookads.adobjects.adcreativeobjectstoryspec \
import AdCreativeObjectStorySpec
from facebookads.adobjects.adpreview import AdPreview
account = AdAccount('act_<AD_ACCOUNT_ID>')
link_data = AdCreativeLinkData()
link_data.set_data({
AdCreativeLinkData.Field.image_hash: '<IMAGE_HASH>',
AdCreativeLinkData.Field.message: 'Ad message',
AdCreativeLinkData.Field.caption: 'www.example.com',
AdCreativeLinkData.Field.link: '<URL>',
AdCreativeLinkData.Field.call_to_action: {
'type': AdCreativeLinkDataCallToAction.Type.learn_more,
'value': {
'link': '<URL>',
},
},
})
story = AdCreativeObjectStorySpec()
story.set_data({
AdCreativeObjectStorySpec.Field.page_id: <PAGE_ID>,
AdCreativeObjectStorySpec.Field.instagram_actor_id: <INSTAGRAM_ACTOR_ID>,
AdCreativeObjectStorySpec.Field.link_data: link_data,
})
creative = AdCreative()
creative.set_data({
AdCreative.Field.object_story_spec: story,
})
preview = account.get_generate_previews(params={
'creative': creative,
'ad_format': AdPreview.AdFormat.instagram_standard,
})
APINodeList<AdPreview> adPreviews = new AdAccount(act_<AD_ACCOUNT_ID>, context).getGeneratePreviews()
.setCreative(
new AdCreative()
.setFieldObjectStorySpec(
new AdCreativeObjectStorySpec()
.setFieldInstagramActorId(<INSTAGRAM_ACTOR_ID>)
.setFieldLinkData(
new AdCreativeLinkData()
.setFieldCallToAction(
new AdCreativeLinkDataCallToAction()
.setFieldType(AdCreativeLinkDataCallToAction.EnumType.VALUE_LEARN_MORE)
.setFieldValue(
new AdCreativeLinkDataCallToActionValue()
.setFieldLink(<URL>)
)
)
.setFieldCaption("www.example.com")
.setFieldImageHash(<IMAGE_HASH>)
.setFieldLink(<URL>)
.setFieldMessage("Ad Message")
)
.setFieldPageId(<PAGE_ID>)
)
)
.setAdFormat(AdPreview.EnumAdFormat.VALUE_INSTAGRAM_STANDARD)
.execute();
curl -G \
--data-urlencode 'creative={
"object_story_spec": {
"instagram_actor_id": "<INSTAGRAM_ACTOR_ID>",
"link_data": {
"call_to_action": {"type":"LEARN_MORE","value":{"link":"<URL>"}},
"caption": "www.example.com",
"image_hash": "<IMAGE_HASH>",
"link": "<URL>",
"message": "Ad Message"
},
"page_id": "<PAGE_ID>"
}
}' \
-d 'ad_format=INSTAGRAM_STANDARD' \
-d 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v2.11/act_<AD_ACCOUNT_ID>/generatepreviews
After you provide ad creative, you can get the URL for the corresponding Instagram post, and can see responses to the ad post. The post is not identical to the one your audience sees. It does not have "Sponsored" or a call-to-action.
This URL is not available with Dynamic Ad creatives, which is when you use template_data
in object_story_spec
. This URL is also unavailable for ad creatives for ads in Instagram stories.
curl -X GET \
-d 'fields="instagram_permalink_url"' \
-d 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v21.0/<CREATIVE_ID>/
The response:
{ "instagram_permalink_url": "<INSTAGRAM_POST_URL>", "id": "<AD_CREATIVE_ID>" }