Ron Badur
Ron Badur

Reputation: 1973

create ad that related to instagram post with facebook marketing api

TL;DR: how to create ad in business manager that connected to instagram post?

I am using facebook marketing api to creating ads in the business manager that promote posts from my facebook page. I have instagram business account that connected with my facebook page and I want to be able creating ad with posts from my instagram account through the facebook marketing api (or any other api), this is possible?

my code for creating ads with posts from my facebook page:

Creating ad creative

adsSdk.FacebookAdsApi.init(accessToken);

const AdAccount = adsSdk.AdAccount;
const account = new AdAccount(accountId);

let fields = ['id', 'object_story_id'];
let params = {
    'name': 'Ad Creative test',
    'effective_instagram_story_id': facebookPostId
};

account.createAdCreative(fields, params).then(res =>{
    console.log(`ad creative created successfully with id ` + res.id);
});

Creating ad

adsSdk.FacebookAdsApi.init(accessToken);

const AdAccount = adsSdk.AdAccount;
const account = new AdAccount(accountId);

let fields = ['id'];
let params = {
    'name': 'New Ad',
    'adset_id': adsetId,
    'creative': '{\'creative_id\':' + creativeId + '}',
    'status': 'PAUSED',
};

account.createAd(fields, params).then(res => {
    console.log(`ad created successfully with id ` + id);
});

If I just giving instagram post id instead of facebook post id I get error.

Thanks for any kind of help :)

Upvotes: 2

Views: 1155

Answers (1)

dhyanandra singh
dhyanandra singh

Reputation: 1141

Create add using

new AdAccount(id, context).createAdCreative()
      .setName("Promoted Post")
      .setObjectStoryId("<pageID>_<postID>")
      .execute();

You can verify that your instagram account is linked using instagram_accounts if not try page_backed_instagram_accounts

for verify try to implement:

https://graph.facebook.com/v3.2/[pageId]?fields=instagram_accounts https://graph.facebook.com/v3.2/[pageId]?fields=page_backed_instagram_accounts

Upvotes: 0

Related Questions