Possible to specify date_preset with insights edge in Facebook Ads API?

风格不统一 提交于 2019-12-05 08:39:01

Yes this is possible using query expansion, however you probably should not do it in this anyway.

Using query expansion results in multiple requests being executed in one HTTP call, in this case one to get all the adcampaigns, and then N requests where N is the number of adcampaigns returned. This will in turn affect your rate limiting.

The most efficient way to request all insights for all adcampaigns (ad sets) is instead to request them at the account level, specifying aggregation level:

/v2.4/act_{ADACCOUNT_ID}/insights?date_preset=last_7_days&level=campaign

This requires just 1 request, or the number of requests to retrieve the total number of pages.

If you really want to achieve this with query expansion, you can do the following for example:

/v2.4/act_{ADACCOUNT_ID}/adcampaigns?fields=insights.date_preset(last_30_days).time_increment(all_days)

You can see the parameters to insights that would normally be query parameters of the form param_name=param_value are now in the form of param_name(param_value).

To specify the date_preset , here is the correct format . Its important to use insights as edge to get the date_preset filtering .

/v2.10/act_{ADACCOUNT_ID}/insights?fields=impressions,clicks,ctr,unique_clicks,unique_ctr,spend,cpc&date_preset=last_3d

The above one is tested with latest Graph Api version(2.10) as of now . FOr more info related to the date_preset values refer to there api docs .

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!