MyNixOS website logo
Description

Loading Data from 'Google Ads API'.

Interface for loading data from 'Google Ads API', see <https://developers.google.com/google-ads/api/docs/start>. Package provide function for authorization and loading reports.

rgoogleads: R package for work with Google Ads API

CRANstatus R-CMD-check Lifecycle: experimental

Table of Contents

Links

This section contains links to the package documentation, as well as other useful links that may be useful to the package users.

Install

You can install rgoogleads from CRAN or GitHub:

# install from CRAN
install.packages('rgoogleads')
# install from github
devtools::install_github('selesnow/rgoogleads')

Attach rgoogleads

library(rgoogleads)

Main goal and capabilities of rgoogleads

rgoogleads is R client for work with Google Ads API v8. Main goal of rgoogleads - load report data from Google Ads client account into R for analysis and visualizations.

Capabilities of rgoogleads:

  • Authorization in the Google Ads API
  • Loading a list of top-level accounts
  • Loading the entire hierarchy of accounts from manager accounts
  • Loading list of Google Ads client account objects: campaigns, ad groups, ads, etc.
  • Loading statistics from Google Ads client account
  • Loading resource metadata, resource fields, segments and metrics
  • Loading forecast and historical metrics from Keyword Planning.

Privacy Policy

The rgoogleads package for authorization uses the gargle package, the credentials obtained during authorization are stored exclusively on your local PC, you can find out the folder into which the credentials are cached using the gads_auth_cache_path() function.

For loading data from Google Ads Account rgoogleads needs https://www.googleapis.com/auth/adwords scope (Manage Your Google AdWords Campaigns), see official Google Ads API documentation.

The package does not transfer your credentials or data obtained from your advertising accounts to third parties, however, the responsibility for information leakage remains on the side of the package user. The author does not bear any responsibility for their safety, be careful when transferring cached credentials to third parties.

For more details, I recommend that you read the following articles from the official documentation of the gargle package:

Authorization process

You run gads_auth('[email protected]') and start OAuth Dance in the browser:

Typical OAuth dance in the browser, when initiated from within R

Upon success, you see this message in the browser:

Authentication complete. Please close this page and return to R.

And you credentials cached locally on your PC in the form of RDS files.

Key points

  • By default, gargle caches user tokens centrally, at the user level, and their keys or labels also convey which Google identity is associated with each token.
  • Token storage relies on serialized R objects. That is, tokens are stored locally on your PC in the form of RDS files.

Use own OAuth client

You can use own OAuth app:

app <- httr::oauth_app(appname = "app name", key = "app id", secret = "app secret")
gads_auth_configure(app = app)

# or from json file 
gads_auth_configure(path = 'D:/ga_auth/app.json')

# run authorization
gads_auth('[email protected]')

Obtain Own Developer Token and create own OAuth client

For obtain own developer token and OAuth client read the following documentation:

Example of use rgoogleads

library(rgoogleads)

# set own oauth app
gads_auth_configure(path = 'C:/auth/app.json')
# set your developer token if needed, or use default developer token
gads_auth(email = '[email protected]', developer_token = "own developer token")

# get list of accessible accounts
my_accounts <- gads_get_accessible_customers()

# set manager account id (options)
gads_set_login_customer_id('xxx-xxx-xxxx')

# set client account id
gads_set_customer_id('xxx-xxx-xxxx')

# load report data
ad_group_report <- gads_get_report(
  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")
)

Package help

For get help of rgoogleads use ?rgoogleads or ?gads_get_report.

Package chage log, news and updates

You can follow the package updates at the link.

Bug report and support

If you encounter an error in the package, or you have suggestions for improving its functionality, you can create a issue using the link.

Tutorials

This section contains links to articles dedicated to rgoogleads.

If you have published an article about rgoogleads let me know about it in telegram or email and I will add it to the list of links.

Author

Alexey Seleznev, Head of analytics dept. at Netpeak
Telegram Channel: R4marketing
email: [email protected]
facebook: facebook.com/selesnow
blog: alexeyseleznev.wordpress.com.

Metadata

Version

0.11.0

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows