Facebook insights API not returning all expected fields?
curl -G \ -d "fields=campaign_name,adset_id,adset_name,impressions,clicks,cpc,spend,date_start,date_stop" \ -d "time_range={'since':'2023-07-01','until':'2023-09-30'}" \ -d "access_token=${FACEBOOK_ACCESS_TOKEN}" \ https://graph.facebook.com/v21.0/act_"$FACEBOOK_ACCOUNT_ID"/insights
Returns
{ "data": [ { "impressions": "*******", "clicks": "*****", "cpc": "*****", "spend": "**********", "date_start": "2023-09-25", "date_stop": "2023-09-30" } ], "paging": { "cursors": { "before": "****", "after": "****" } } }
Why is it not returning the other fields like campaign_name, adset_id etc?? I'm getting the field names from here: https://github.com/facebook/facebook-php-business-sdk/blob/7ec7292c1ce3c78e2005d730da0092e28458af95/src/FacebookAds/Object/Fields/AdsInsightsFields.php#L46
https://developers.facebook.com/docs/marketing-api/insights/#levels
I needed to set the level parameter: -d "level=adset" \