Type: | Package |
Title: | Google Ads Data Hub API Client |
Version: | 0.1.1 |
Author: | Pankaj Bhatlawande |
Maintainer: | Pankaj Bhatlawande <pbhatlawande@merkleinc.com> |
Description: | Interact with Google Ads Data Hub API https://developers.google.com/ads-data-hub/reference/rest. The functionality allows to fetch customer details, submit queries to ADH. |
License: | GPL-2 |
Encoding: | UTF-8 |
LazyData: | true |
RoxygenNote: | 7.1.1 |
Imports: | httr, jsonlite, lubridate |
NeedsCompilation: | no |
Packaged: | 2021-02-02 16:51:21 UTC; pbhatlawande |
Repository: | CRAN |
Date/Publication: | 2021-02-08 10:10:02 UTC |
create_query
Description
Creates an analysis query for later execution. No query validation is performed at this time. Reference: <https://developers.google.com/ads-data-hub/reference/rest/v1/customers.analysisQueries/create>
Usage
create_query(customer_id, query_title, query_text, token)
Arguments
customer_id |
ADH Customer ID e.g. customers/123 |
query_title |
Query title, which is unique within a single Ads Data Hub customer and query type. e.g.RnF Analysis |
query_text |
Query text written in Standard SQL. |
token |
Access token retrived from function google_auth() |
Value
If successful, the response body contains a newly created instance of the query
Examples
## Not run:
library(adsDataHubR)
token <- google_auth(client_id = client_id, client_secret=client_secret)
create_query(customer_id, query_title, query_text, token)
## End(Not run)
get_adh_links
Description
Lists links between the specified customer and other Google advertising entities.
Usage
get_adh_links(customer_id, token)
Arguments
customer_id |
ADH Customer ID e.g. customers/123 |
token |
Access token retrived from function google_auth() |
Value
A list of ad data links.
Examples
## Not run:
library(adsDataHubR)
token <- google_auth(client_id = client_id, client_secret=client_secret)
total_customers <- get_customers(token)
customer_id <- "customers/123456"
get_adh_links(customer_id, token)
## End(Not run)
get_customers
Description
Fetch Ads Data Hub customers to which the current user has access. Reference: <https://developers.google.com/ads-data-hub/reference/rest/v1/customers.adsDataLinks/list>
Usage
get_customers(token)
Arguments
token |
Access token retrived from function google_auth() |
Value
A dataframe of all customers along with IDs to which authenticated user has access
Examples
## Not run:
library(adsDataHubR)
total_customers <- get_customers(token)
## End(Not run)
get_query
Description
Retrieves the requested analysis query. Reference: <https://developers.google.com/ads-data-hub/reference/rest/v1/customers.analysisQueries/get>
Usage
get_query(query_name, token)
Arguments
query_name |
e.g.customers/123/analysisQueries/abcd1234 |
token |
Access token retrived from function google_auth() |
Value
A list of query details
Examples
## Not run:
library(adsDataHubR)
token <- google_auth(client_id = client_id, client_secret=client_secret)
get_query(query_name, token)
## End(Not run)
google_auth
Description
Function to login and create a token to be used in all the funtions Reference: <https://developers.google.com/ads-data-hub/guides/quickstart-api>
Usage
google_auth(client_id, client_secret)
Arguments
client_id |
Client ID |
client_secret |
Client Secret |
Value
Environment token that can be used in all other functions
See Also
https://developers.google.com/ads-data-hub/guides/quickstart-api
Examples
## Not run:
token <- google_auth(client_id = client_id, client_secret=client_secret)
## End(Not run)
list_queries
Description
Lists links between the specified customer and other Google advertising entities. Reference: <https://developers.google.com/ads-data-hub/reference/rest/v1/customers.analysisQueries/list>
Usage
list_queries(customer_id, token)
Arguments
customer_id |
ADH Customer ID e.g. customers/123 |
token |
Access token retrived from function google_auth() |
Value
A list of analysis queries run on the ADH customer account.
Examples
## Not run:
library(adsDataHubR)
token <- google_auth(client_id = client_id, client_secret=client_secret)
total_customers <- get_customers(token)
customer_id <- "customers/123456"
list_queries(customer_id, token)
## End(Not run)
start_query
Description
Starts execution on a stored analysis query. The results will be written to the specified BigQuery destination table. The returned operation name can be used to poll for query completion status.. Reference: <https://developers.google.com/ads-data-hub/reference/rest/v1/customers.analysisQueries/start>
Usage
start_query(
query_name,
ads_data_customer_id,
bq_destination_table,
start_date,
end_date,
token
)
Arguments
query_name |
e.g. customers/123/analysisQueries/abcd1234' |
ads_data_customer_id |
#Enter the "From" ADH account on which we want to run the query |
bq_destination_table |
BigQuery destination table ID e.g. "project.dataset.table_name" If specified, the project must be explicitly whitelisted for the customer's ADH account. If project is not specified, uses default project for the provided customer. If neither project nor dataset is specified, uses the default project and dataset. |
start_date |
Start Date e.g. 2021-01-31 format: YYYY-MM-DD |
end_date |
End Date e.g. 2021-01-31 format: YYYY-MM-DD |
token |
Access token retrived from function google_auth() |
Value
If successful, the response body contains an instance of the submitted job.
Examples
## Not run:
library(adsDataHubR)
token <- google_auth(client_id = client_id, client_secret=client_secret)
start_query(query_name, ads_data_customer_id, bq_destination_table, start_date, end_date, token)
## End(Not run)
validate_query
Description
Performs static validation checks on the provided analysis query. Reference: <https://developers.google.com/ads-data-hub/reference/rest/v1/customers.analysisQueries/validate>
Usage
validate_query(customer_id, query_instance, token)
Arguments
customer_id |
ADH Customer ID e.g. customers/123 |
query_instance |
Query instance returned by create_query function |
token |
Access token retrived from function google_auth() |
Value
If successful, the response body contains a validation queryPerformanceInfo object
Examples
## Not run:
library(adsDataHubR)
token <- google_auth(client_id = client_id, client_secret=client_secret)
validate_query(customer_id, query_instance, token)
## End(Not run)