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,
2
Answers
To retrieve insights data in day-granularity from the Facebook API, you can make use of the following request:
In your previous request, you were missing the time_increment parameter, which specifies the granularity of the data. By adding &time_increment=1, you will retrieve the insights data on a daily basis.
Once you make this request, the response should provide you with the desired day-granularity metrics for your ad. Each data object in the response will represent a single day, allowing you to analyze the performance on a daily basis.
Please note that the example response you provided seems to summarize the metrics for the entire time range rather than providing daily data. By including the time_increment parameter in your request, you should receive the data in the desired granularity.
You need to modify your API request by adding the
time_increment
(enum{monthly, all_days} or integer
) parameter with a value of1
for daily. Try;You should receive daily granularity data in the response. Screenshot of time_increment on Meta Dev and website ref for some fun reading.