Some notes on using the FB Marketing Insights API to build a dashboard similar to Facebook Ads Manager Reporting --
The API docs appear very thorough, but are missing an exhaustive list of fields that you'd need to build a generic reporting tool. In my first attempt, I pulled all fields from these docs, but found a lot of discrepencies when compared to FB's UI.
It's more productive to scrape the visible options from FB's own UI, which can be done like this:
- Visit Facebook Ads Manager Reporting and open the report builder
- Select the Breakdowns tab
- Use this nasty JS snippet in the dev console
- Select the Metrics tab and repeat
Object.fromEntries(
// Selects all checkbox elements
[...document.querySelectorAll('._920x')]
// Maps to the React props of each component
.map(n => n[Object.keys(n).find(k => k.startsWith('__reactProps'))].children[0].props)
// Maps to an object entry tuple of [apiField, userLabel]
.map(p => ([p.columnId, p.label.$2 || p.label || '<undefined>' ]))
)