Turn a google_analytics style call into BigQuery SQL. Used with Google Analytics 360 BigQuery exports.
google_analytics_bq(
projectId,
datasetId,
start = NULL,
end = NULL,
metrics = NULL,
dimensions = NULL,
sort = NULL,
filters = NULL,
max_results = 100,
query = NULL,
return_query_only = FALSE,
bucket = NULL,
download_file = NULL
)
The Google project Id where the BigQuery exports sit
DatasetId of GA export. This should match the GA View ID
start date
end date
metrics to query
dimensions to query
metric to sort by
filter results
How many results to fetch
If query is non-NULL then it will use that and ignore above
Only return the constructed query, don't call BigQuery
if over 100000 results, specify a Google Cloud bucket to send data to
Where to save asynch files. If NULL saves to current working directory.
data.frame of results
All data will be unsampled, and requests will cost money against your BigQuery quota.
Requires installation of bigQueryR and authentication under ga_bq_auth()
or googleAuthR::gar_auth() with BigQuery scope set.
View your projectIds upon authentication via bigQueryR::bqr_list_projects()
No segments for now.
Goals are not specified in BQ exports, so you need to look at how you define them and replicate per view e.g. unique pageviews or unique events.
Custom dimensions can be specified as session or hit level, so ignoring the setting in GA interface.
You can get a sample Google Analytics dataset in bigquery by following the instructions here: https://support.google.com/analytics/answer/3416091?hl=en