Search code examples
facebook-graph-apifacebook-marketing-api

Include Adset details Insights query


Using the Facebook Marketing API (Graph API), I use the following (simplified for brevity) query:

act_xxxxxx/insights?level=adset&fields=date_start,date_stop,clicks,adset_name

This gives me a result like this:

{
"data": [
 {
  "date_start": "2019-01-01",
  "date_stop": "2019-01-30",
  "clicks": "999",
  "adset_name": "Awesome Adset"
 }
 ] //paging info removed, not relevant
}

For each node in data, I would like to include some properties from the adset, like end_time,start_time,lifetime_budget,daily_budget.

I have looked into expanding fields, but there does not seem to be an adset field I can expand on here.

Is there a way to include adset fields like lifetime_budget, so I can get the results in one go?

Right now, query adsets separately and join afterwards, but I think there must be a way to get it in one resultset.


Solution

  • You could query adsets and ask for all the fields you need adding with the parenthesis notation each kind of params you need, as example, for ask about all the adsets with budgets info and bid strategy of an adAccount with insights with specified metrics, you can use the following:

    act_XXXX/adsets?fields=insights{clicks,spend,cpc},lifetime_budget,daily_budget,name,start_time,end_time
    

    Hope this help