Facebook marketing API: How to get the optimization event

Viewed 194

Using the NodeJs (and also the REST API) Facebook marketing API I'm trying to know which Ad Sets are optimizing which event (e,g, add_to_wishlist)

To do that I'm fetching all ad sets:

import bizSdk = require('facebook-nodejs-business-sdk'); // v8.0.0

bizSdk.FacebookAdsApi.init('myaccesstoken')
const adAccount = new bizSdk.AdAccount('act_XXXXX');
const adSets= await adAccount.getAdSets([bizSdk.AdSet.Fields.optimization_sub_event,bizSdk.AdSet.Fields.optimization_goal]);

I always get NONE for the optimization_sub_event field and VALUE or OFFSITE_CONVERSIONS for optimization_goal

More over, I tried to fetch ALL fields possible and look for my event names but without success.

Is there away to achieve that using the API?

1 Answers

Fetch the field promoted_object. The value for a custom event will have this structure:

promoted_object: {
  "application_id": "994*******818",
  "custom_event_type": "OTHER",
  "object_store_url": "http://play.google.com/store/apps/details?id=com.*****",
  "custom_event_str": "my_custom_event_name" // this is what you want
}
Related