Learn R Programming

adwordsR

adwordsR: R package for accessing the Google Adwords API.

This package provides an authetication process for the Google API via OAUTH2. It also accesses the API using SOAP requests and building XML files. Currently, there is only the Managed Customer Service service is supported through the package, however further packages are planned to built into the package.

Guide

You will need an MCC account in Adwords, which can be simply created. Through your MCC, you can apply for an Adwords Developer Token, to gain access to the API. You will also need a Client ID and Client Secret. To get these, you will need to set up a Google API project, which will provide you with a Client ID and Secret.

Authentication

To load or generate your Adwords Authentication token:

credentials <- loadAdwordsToken()

If you already have a token in your working directory, then this will be loaded using this command. If not, a token will be generated provided you enter the correct authentication details.

To check your Authentication token:

credentials <- checkAdwordsToken()

This will refresh the token if it has expired.

Example: Build your requests

To access the API, you need to build your XML request. This is not necessary for the reporting side of the API.

For Reporting:

Please note that this is a basic example and does not represent the full functionality. Please reference the help documentation for each R function.

credentials <- loadAdwordsToken()

credentials <- checkAdwordsToken()

data <- getReportData("KEYWORDS_PERFORMANCE_REPORT", 
                      "2018-01-01", 
					  "2018-02-01", 
					  "123-123-4567", 
					  credentials, 
					  attributes = c("Criteria", 
					                 "Date", 
									 "Impressions"))
				   

For Other Services

Please note that this is a basic example and does not represent the full functionality. More complex XML queries can be built. Please reference the help documentation for each R function.

credentials <- loadAdwordsToken()

xml <- buildXmlEnvelope("123-123-1234",  
                        "myUserAgent", 
						credentials$adwordsDeveloperToken, 
						"ManagedCustomerService", 
						c("CustomerId", 
						  "Name"))					   

credentials <- checkAdwordsToken()

data <- getXmlRequest("ManagedCustomerService", 
                      xml,
					  credentials)

Copy Link

Version

Install

install.packages('adwordsR')

Monthly Downloads

256

Version

0.3.1

License

MIT + file LICENSE

Maintainer

Last Published

June 19th, 2018

Functions in adwordsR (0.3.1)

checkAdwordsToken

Check Adwords Token
addToGitignore

Add to .gitignore
generateAdwordsToken

Initial Adwords Token
apiDetails

Google API Authentication Details
buildXmlEnvelope

Build XML Envelope
refreshAdwordsToken

Refresh Adwords Token
buildXmlHeader

Build XML Header
TargetingIdeaService_relatedToUrlSearchParameter

TargetingIdeaService - Related to URL Search Parameter
loadAdwordsToken

Load Adwords Token
buildAwqlStatement

AWQL Statement
TargetingIdeaService_searchVolumeSearchParameter

TargetingIdeaService - Search Volume Search Parameter
buildXmlBody

Build XML Body
getXmlRequest

Send XML Request
getReportData

Retrieve Adwords Data
TargetingIdeaService_get

TargetingIdeaService - Get
ManagedCustomerService_get

Customer Manager Service Get Request
TargetingIdeaService_ideaTextFilterSearchParameter

TargetingIdeaService - Indea Text Filter Search Parameter
ManagedCustomerService_serviceSelector

Customer Manager Service Selector
TargetingIdeaService_languageSearchParameter

TargetingIdeaService - Language Search Parameter
TargetingIdeaService_seedAdGroupIdSearchParameter

TargetingIdeaService - Seed Ad Group Id Search Parameter
TargetingIdeaService_networkSearchParameter

TargetingIdeaService - Network Search Parameter
TargetingIdeaService_selector

TargetingIdeaService - Selector
TargetingIdeaService_paging

TargetingIdeaService - Paging Request
TargetingIdeaService_includeAdultContentSearchParameter

TargetingIdeaService - Include Adult Content Search Parameter
TargetingIdeaService_ideaType

TargetingIdeaService - Idea Types
TargetingIdeaService_searchParameters

TargetingIdeaService - Search Parameter
TargetingIdeaService_locationSearchParameter

TargetingIdeaService - Location Search Parameter
TargetingIdeaService_requestType

TargetingIdeaService - Request Types
TargetingIdeaService_requestedAttributeTypes

TargetingIdeaService - Attribute Types
TargetingIdeaService_categoryProductsAndServicesSearchParameter

TargetingIdeaService - Category Products and Services Search Parameter
TargetingIdeaService_relatedToQuerySearchParameter

TargetingIdeaService - Related to Query Search Parameter
TargetingIdeaService_competitionSearchParameter

TargetingIdeaService - Competition Search Parameter