Learn R Programming

fbRads (version 17.0.0)

fb_insights: Insights

Description

Insights

Usage

fb_insights(
  fbacc,
  target = fbacc$acct_path,
  job_type = c("sync", "async"),
  retries = 0,
  simplify = TRUE,
  ...
)

Value

list of data.frame or list objects depending on the simplify argument

Arguments

fbacc

(optional) FB_Ad_account object, which defaults to the last returned object of fbad_init.

target

ad account id(s) (default), campaign id(s), adset id(s) or ad id(s)

job_type

synchronous or asynchronous request. If the prior fails with "please reduce the amount of data", it will fall back to async request. Async query is possible with only one target.

retries

number of times this query has been sent to Facebook previously and failed -- to be used internally for error handling

simplify

return a list of data.frame or list objects

...

named arguments passed to the API, like time range, fields, filtering etc.

References

https://developers.facebook.com/docs/marketing-api/insights

Examples

Run this code
if (FALSE) {
fb_insights(fbacc)

## get default fields and filter for a few metrics
l <- fb_insights(date_preset = 'today', level = 'ad')
## merge pages into tabular data
data.table::rbindlist(l)

## sometimes more advanced list selections are needed
l <- fb_insights(date_preset = 'today', level = 'ad', fields = 'unique_actions', simplify = FALSE)

## filter for ACTIVE Ads
l <- fb_insights(date_preset = 'today', level = 'ad',
  filtering = "[{'field':'adset.effective_status','operator':'IN','value':['ACTIVE']}]")
}

Run the code above in your browser using DataLab