Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook Graph Api returning empty data for Ad Insights API

I am trying to fetch reporting for the AdCampaign let's say with xyz id, I have valid access token with ads_read, read_insights permissions & everything else except page_messaging. The app with the permitted token is owned by same ad account as well.

xyz/insights?fields=ad_name,....

No matter which fields I ask for, it always return me empty data set.

{
  "data": [
  ]
}
like image 961
user1064504 Avatar asked Dec 20 '25 17:12

user1064504


2 Answers

For awhile I also struggled with this issue.

What is probably going on is that no ads are being returned for the default parameters of the query. For example, by default Ad Insights looks at only the last 30 days of the advertisement's lifetime. Try setting the 'date_preset' parameter to 'lifetime'. For your query that would look like:

xyz/insights?date_preset=maximum&fields=ad_name,....

For more info, check this page: https://developers.facebook.com/docs/marketing-api/reference/adgroup/insights/.

Additional ref: https://developers.facebook.com/docs/marketing-api/insights/parameters/v17.0

like image 93
Dario Macieira Avatar answered Dec 24 '25 08:12

Dario Macieira


@Dario-macieira is correct but now the date_preset = lifetime parameter is disabled in Graph API v10.0+ and replaced with date_preset = maximum, which returns a maximum of 37 months of data.

For v9.0 and below, date_preset = maximum will be enabled on May 25, 2021, and any lifetime calls will default to maximum and return only 37 months of data.

https://developers.facebook.com/docs/marketing-api/insights/parameters/v12.0

like image 22
Meli Avatar answered Dec 24 '25 09:12

Meli