library(r4googleads)
<- authenticate() google_auth
In addition to Google queries {r4googleads} comes with built-in support for GoogleAds services and listing accessible customers. Please notice that all examples assume that you have a working GoogleAds setup (MCC, Client ID, Client Secret, Developer Token and client token) and that you’re authenticated successfully using {r4googleads}.
First create the corresponding R object of class GoogleAdsFields and set its parameters that will be send to Google.
= googleAdsFields(
report_schema tbl = "campaign", # e.g. campaign report
api_version = 'v9'
)
Pass the newly created object to the standard query_google_ads function
<- query_google_ads(
campaign_report_schema mcc_id = '***-***-****', # Google Ads My Client Center ID
google_auth = google_auth,
service = report_schema,
raw_data = F
)
and received the desired answer based on the parameters and class of the object.
> str(campaign_report_schema)
13
List of $ resourceName : chr "googleAdsFields/campaign"
$ category : chr "RESOURCE"
$ dataType : chr "MESSAGE"
$ name : chr "campaign"
$ selectable : logi FALSE
$ filterable : logi FALSE
$ sortable : logi FALSE
$ selectableWith : chr [1:194] "accessible_bidding_strategy" "bidding_strategy" "campaign_budget" "customer" ...
$ attributeResources: chr [1:4] "accessible_bidding_strategy" "bidding_strategy" "campaign_budget" "customer"
$ metrics : chr [1:84] "metrics.absolute_top_impression_percentage" "metrics.active_view_cpm" "metrics.active_view_ctr" "metrics.active_view_impressions" ...
$ segments : chr [1:24] "segments.ad_destination_type" "segments.ad_network_type" "segments.click_type" "segments.conversion_action" ...
$ typeUrl : chr "com.google.ads.googleads.v9.resources.Campaign"
$ isRepeated : logi FALSE
Listing available accounts works in similar fashion.
<- listAccessibleCustomers(api_version = 'v9')
list_customer_service
<- query_google_ads(
customers mcc_id = '***-***-****', # Google Ads My Client Center ID
google_auth = google_auth,
service = list_customer_service,
raw_data = F
)
… customers a simple list of resources.
> customers
$resourceNames
1] "customers/8880XXXXX" [