daroczig / fbRads

Analyze and manage Facebook ads from R using this client library to access their Marketing APIs
GNU Affero General Public License v3.0
153 stars 57 forks source link

fb_insights only fetches last breakdown value #133

Open hhissami opened 3 years ago

hhissami commented 3 years ago

Hi,

When multiple breakdown values get passed into fb_insights(), it only returns the last breakdown as a column in the resulting dataframe.

For example:

insights_list <- fb_insights(target=campaign_id, level="ad", date_preset = "lifetime", fields=c("ad_name"), breakdowns = c("gender", "age"))

returns a dataframe with the following columns:

$ ad_name  <chr>
$ date_start <chr>
$ date_stop  <chr>
$ age  <chr>

Note there is an age column but no gender column.

I tested this with other breakdown values, and the same pattern always holds where only the last breakdown value ends up as a column.

sayac007 commented 3 years ago

Don't use "c(", note that your command is just converted into a URL which should be formatted according to Facebook guidelines, see here for examples: https://developers.facebook.com/docs/marketing-api/insights/breakdowns#combiningbreakdowns

In your case, simply use "breakdowns="gender, age"", without "c(".