I am trying to filter adsets insights by adset status, but when I add a status filter, I get an empty dataset back:
curl "https://graph.facebook.com/v2.7/act_<redacted>/insights?fields=clicks,impressions,cpc,ctr,account_id&time_range%5Bsince%5D=2016-01-12&time_range%5Buntil%5D=2016-09-12&access_token=<redacted>&format=json&filtering=%5B%7B%22field%22:%22status%22,%22operator%22:%22EQUAL%22,%22value%22:%22ACTIVE%22%7D%5D&level=adset"
here is what filtering param looks like before it gets url-encoded:
[{"field":"status","operator":"EQUAL","value":"ACTIVE"}]
I have tried all valid values for status ACTIVE, PAUSED, DELETED, ARCHIVED
to no avail.
When I remove filtering param – I see my data.
The question is:
Does anyone know if it is possible to filter by status, and if it is, what I am doing wrong?
3
Answers
Filtering by insights isn't possible. At least in v2.7. To get insights for let's say ads I've decided to do the following: 1. Fetch ads that I need via
/ads
call. This allows me to filter by status. 2. Fetch insights for the same collection of ads and make sure that I ad id is included in the response. 3. Filter the second collection using the first one.i m using this to filter campaigns with insights , working for me , start playing with it
dont forget to json_encode $campaigncheckstatus if passed through url
It is possible. Using latest version as of March 2018.
You need to actually request all the ads that are ACTIVE and then provide
insights
as a ‘nested’ list of fields.Replace 123456 with your ad account (but leave the
'act_'
which is needed)This also works for
/campaigns
and/adsets
You can also do this (be sure to include
&level=ad
):