Migrate from RAdwords to rgoogleads

  collapse = TRUE,
  eval = FALSE,
  comment = "#>"

The problem is that the RAdwords package is used to work with Google AdWords API v201809. This API has not been updated for a long time and will stop working on 27 April 2022.

In this vignette, I want to share some information on a new package, rgoogleads, which I started working on in June 2021. The package currently has all the functions needed to request the function data. Next, we will go through the details of how to switch from RAdwords to rgoogleads, so that from April 2022, your scripts will still correctly collect the necessary data from your Google Ads accounts.

rgoogleads package features

The rgoogleads package currently includes all the functions needed to fetch data from the Google Ads API:

rgoogleads package benefits

Now let's look at the benefits of switching to the new rgoogleads package:

Key differences between the Google AdWords API and Google Ads API

Fortunately, there are few key differences between the old and new APIs, and the migration process isn’t that difficult. Let me enumerate the key points of the migration below.

Migrating from RAdwords to rgoogleads

migrate_table <- data.frame(
  operation = c("Authorization", "Metadata request", "Report request"),
  radwords = c("doAuth()", "reports(), metrics()", "statement() + getData()"),
  rgoogleads = c("gads_auth_configure() + gads_auth()", "gads_get_metadata(), gads_get_fields()", "gads_get_report()")

  colnames = c("Operation", "RAdwords", "rgoogleads"),
  options = list(pageLength = 5, dom = 'tip'))

The former report types in Google AdWords have become resources in Google Ads. See the comparison table from the official help guide:

# reports_table <- data.frame(
#   ads     = c("customer", "ad_group_ad", "ad_group", "age_range_view",
#               "campaign_audience_view, ad_group_audience_view", "group_placement_view", "bidding_strategy", "campaign_budget",
#               "call_view", "ad_schedule_view", "campaign_criterion", "campaign",
#               "campaign_shared_set", "location_view", "click_view", "display_keyword_view"))

reports <- read_html("https://developers.google.com/google-ads/api/docs/migration/mapping") %>% 
           html_element(css = ".responsive") %>% 
           html_table(header = TRUE)

  colnames = c("Тип отчёта в Google AdWords API", "Ресурс в Google Ads API"),
  options = list(pageLength = 20)

See the official help guide for the correspondence between the "Report" and the resource fields. The table is large, so there’s no need to duplicate it here.

See the example of requesting a campaign performance report with the same set of fields, using the RAdwords package and rgoogleads below.

The request of ad campaign performance report using RAdwords


# auth
adwords_auth <- doAuth()

# create request
query <- statement(
  select = c('CampaignName',
  start  = '2021-06-01',
  end    = '2021-06-30'

# data import
data1 <- getData(
  clientCustomerId = 'xxx-xxx-xxxx',
  statement        = query, 
  google_auth      = adwords_auth

The request of ad campaign performance report using rgoogleads


# auth
gads_auth_configure(path = 'D:/ga_auth/app.json')
gads_auth(email = 'me@gmail.com')

# data import
data2 <- gads_get_report(
  resource = 'campaign',
  fields   = c('campaign.name',
  date_from         = '2021-06-01',
  date_to           = '2021-06-30',
  customer_id       = 'xxx-xxx-xxxx',
  login_customer_id = 'xxx-xxx-xxxx'

Try the rgoogleads package in your browser

Any scripts or data that you put into this service are public.

rgoogleads documentation built on Nov. 24, 2021, 5:08 p.m.