user1064504
user1064504

Reputation: 593

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": [
  ]
}

Upvotes: 2

Views: 3515

Answers (2)

Dario Macieira
Dario Macieira

Reputation: 334

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

Upvotes: 6

Meli
Meli

Reputation: 477

@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

Upvotes: 3

Related Questions