Google Analytics via BigQuery
Last updated
Last updated
When connecting Google Analytics (GA) to BigQuery, your data is stored in a format known as sharding. Table sharding is the practice of storing data in multiple tables, using a naming prefix such as [PREFIX]_YYYYMMDD
. This presents a challenge when doing analytics on the data, as the data is not in a single table (the BigQuery documentation also ).
When importing this directly into Datawisp, Datawisp would treat each shard as a separate table -- this would lead to a very poor experience overall as you end up with hundreds of tables when you logically only really want one.
In order to solve this, we have created this guide to show you how to create a view in BigQuery that will present the data in a single table to Datawisp.
First, we need to create a view in BigQuery that will present the data in a single table to Datawisp. Open the BigQuery console create a new SQL query.
There, paste the following SQL statements:
Make sure to replace <dataset>
with the name of your dataset.
Then press Run.
Then, on the dataset go to Sharing -> Authorize Views.
Authorize the views that you created in the previous step.
Then, on each of the views, grant the BigQuery Data Viewer role.
This setup effectively hides all the sharded tables from Datawisp and only grants access to the views.
Datawisp will now be able to import your GA data correctly.
At this point the GA-specific preparations are complete, so you can now get started with the generic .
Follow this guide until you reach the step . At this point, it is important that you do not grant the BigQuery Data Viewer role on the entire dataset to the service account. Grant the BigQuery Metadata Viewer role instead.
Then, proceed with the of the guide.