if (FALSE) {
# set client id
gads_set_login_customer_id('xxx-xxx-xxxx')
# set manager id if you work under MCC
gads_set_customer_id('xxx-xxx-xxxx')
# default paramas is campaign performance report
campaign_stat <- gads_get_report()
# you can load data from several client accounts at once
# from the same Google Ads MCC
# client ids
accounts <- c('xxx-xxx-xxxx', 'yyy-yyy-yyyy')
# loading data
multi_rep <- gads_get_report(
date_from = as.Date('2021-06-10'),
date_to = as.Date('2021-06-17'),
customer_id = accounts
)
# ------------------
# using more arguments for other reports
group_report <- gads_get_report(
customer_id = 4732519773,
resource = "ad_group",
fields = c("ad_group.campaign",
"ad_group.id",
"ad_group.name",
"ad_group.status",
"metrics.clicks",
"metrics.cost_micros"),
date_from = "2021-06-10",
date_to = "2021-06-17",
where = "ad_group.status = 'ENABLED'",
order_by = c("metrics.clicks DESC", "metrics.cost_micros"),
limit = 30000
)
# ------------------
# parallel loading mode
# note: you must using login_customer_id agrument in parallel mode
# because oprions gads_set_login_customer_id() does't work in parallel mode loading
library(parallel)
# make core cluster
cl <- makeCluster(4)
# loading data
multi_rep <- gads_get_report(
date_from = as.Date('2021-06-10'),
date_to = as.Date('2021-06-17'),
customer_id = c('111-111-1111',
'222-222-2222',
'333-333-3333',
'444-444-4444',
'555-555-5555'),
login_customer_id = "999-999-9999",
cl = cl
)
# stop cluster
stopCluster(cl)
}
Run the code above in your browser using DataLab