I am trying to use the Marketing API to get the summary data for multiple Ad Sets.
I am able to get the data for each Ad Set with the following:
insights/?ids=[**ad_set_ids**]&fields=impressions,clicks,reach,actions,total_actions
I can add up the numbers for each Ad Set to get the total and it is fine except for "reach" because the total of reach doesn't just add up to the total (see image below).
Is there any way to get the summary of data for the ad sets (the last row in the image "Results from 3 Ad Sets")?
I also tried to add the param default_summary=true
but it gives me the summary for each ad set instead of the sum of all ad sets.
What you actually need to use the summary field to achieve this. For example you can query your insights at ad account level and then specify level=adset. Then in the filterring, you specify a list of adset.id. And very important you should add summary=["reach"], so that you can get aggregated reach.
Here is an example:
https://graph.facebook.com/act_[acc_id]/insights?limit=5000&level=adset&summary=["reach"]&date_preset=lifetime&action_attribution_windows=["default"]&filtering=[{"field":"adset.id","operator":"IN","value":[adsetID1]"[","[adsetID2]"]}]
And actually you can do this on a campaign node instead of adaccount node too. It may give you better performance.