Search code examples
apifacebookfacebook-graph-api

How to retrieve insights API for ad in day-granularity on Facebook?


How to retrieve the insights data in day-granularity from Facebook API. This is the request I use:

 

1234548/insights?fields=ad_id,impressions,account_id,created_time,adset_id,campaign_id,clicks,conversions&time_range={'since':'2023-01-01','until':'2023-05-20'}

The response:

  "data": [
    {
      "ad_id": "xxxxxxxx",
      "impressions": "54367",
      "account_id": "xxxxxxxx",
      "created_time": "2023-05-17",
      "adset_id": "xxxxxxxxxxx",
      "campaign_id": "xxxxxxxxxx",
      "clicks": "853",
      "date_start": "2023-01-01",
      "date_stop": "2023-05-20"
    }
  ],
  "paging": {
    "cursors": {
      "before": "MAZDZD",
      "after": "MAZDZD"
    }
  }
}

 

I picked an ad that was created on the 17.5, and expected to receive JSON with the data for a 1-day  granularity, but received the metrics summarized as you can see with the clicks.

 

Any ideas?

 

Thanks,


Solution

  • You need to modify your API request by adding the time_increment (enum{monthly, all_days} or integer) parameter with a value of 1 for daily. Try;

    1234548/insights?fields=ad_id,impressions,account_id,created_time,adset_id,campaign_id,clicks,conversions&time_range={'since':'2023-01-01','until':'2023-05-20'}&time_increment=1
    

    You should receive daily granularity data in the response. Screenshot of time_increment on Meta Dev and website ref for some fun reading.