Back to top button

Linking GA4 to BigQuery after setting up Google Analytics 4

Linking GA4 to BigQuery after setting up Google Analytics 4
In this post, we'll look at quickly setting up Google BigQuery and linking your Google Analytics 4 account and why this should be the first thing you should do after creating a Google Analytics Property.

It's free! It's finally free. So back in the day, if you wanted to link Google Analytics to BigQuery you'd have had to pay, and we mean pay a lot because you would have needed a 360 account, and they don't come cheap. Luckily for us, with the arrival of Google Analytics 4 you can now link your GA4 account to BigQuery for free, well basically free. The option is free, like it's there in your settings on the free tier of GA, but technically BigQuery is paid for, but only technically. So yeah, you pay for BigQuery, which in reality means you credit card will be once you go over the free tier which includes 1TB of queries a month and 10GB of storage, which for the average site is a lot, like a lot a lot. So you know, just do it, you most likely won't get charged and if you think that you're gonna be queuing a lot, just set a warning in the billing settings so Google will pop you an email when you're gonna go over budget.

Anyhow, you may ask, why should we care. Well it's a big deal, you can run all kinds of queries on your data, slice and dice it, combine it with other data sources and whatnot, but most importantly you want to do this for two reasons the moment you set up your account.

Reason 1, well you're most likely gonna end uo building dashboards in Google Data Studio, and while GA 4 is great, it's fresh out the box and just doesn't do everything you might want it to do in Data Studio, so what you'll most likely end up doing is having 2 data sources for that pretty report of your's. One that's just your vanilla GA4 data source and one that pulling your GA4 data from BigQuery. That should have your bases covered, especially if you're gonna be visualising a lot of stuff around events is GA, the BigQuery data source is great fro that.

Reason 2, and this is the main reason you should be doing this, no data is going to be added to BigQuery retroactively if you decide you do actually need it 3 months down the line, they still have GA 360 for that, so if you want all your data in BigQuery right from the start, link it up immediately.

But before we get started, you may be asking, what exactly is BigQuery, well:

BigQuery is a fully-managed, serverless data warehouse that enables scalable analysis over petabytes of data. It is a Platform as a Service that supports querying using ANSI SQL. It also has built-in machine learning capabilities.

So what does that mean and why do I care? It's a big data warehouse you can use on the cheap, that'll allow you to run a lot of really simple, or really complicated queries really quickly. But guys, you might say, I don't need that, to which we'd say, it also connects directly to Data Studio allowing you to visualise your data in a super simple way, no harder than connecting a spreadsheet.

Anyhow, if you're still on the fence, just take the leap, it ain't gonna cost you and you'll have the data down the line if you end top needing it.

What are you going to need to do this?

1 GA 4 Property (Don't have one? Follow this post)

A Google Cloud Account (Get one here)

Admin rights so they actually link properly

Step 1 - Create a Google API Project

  1. Log in to the APIs Console.
  2. Create a new API Project.
  3. Open the Nav Menu top left, click APIs and Services and then click Library.
  4. Under Google Cloud APIs, click BigQuery API and then Enable.
  5. If you're new here do the terms and conditions bit.
  6. Open the Nav again and head to billing, you don't want the free sandbox and your data will eventually be deleted.
  7. Setup a billing account.
  8. Go to https://console.cloud.google.com/bigquery
  9. Create and new data set, if this works your billing is set up.
  10. Now you're going to need a service account (this is the bit about the permission).
  11. Add analytics-processing-dev@system.gserviceaccount.com as a member of the project, and ensure that permission at the project level is set to Editor (as opposed to BigQuery Data Editor). Editor permission is required in order to export data from Analytics to BigQuery.

Step 2 - Link GA4 to Big Query

Go to you GA settings and click on BigQuery Linking

Google Analytics4 Admin

Click Link to create the link.

Linking BigQuery GA4

Click Choose BigQuery Project

GA4 Create BigQuery Link

Choose the project.

GA4 BigQuery Account

Now select the region to run queries, if there are any GDPR implications to what you're doing you're gonna want to go with the EU.

GA4 BigQuery Linking

Now you're going to select your datastream and the frequency, we usually don't bother with streaming, once a day should be just fine for most things. All this means is that you'll always have the data from the day before as the lastes data in BigQuery.

Click submit and you're done.

Google Analytics 4 BigQuery Stream Selection

Some time in the next day you data will start appearing in BigQuery. So wait a day, head to Data Studio, create a new Data Source select BigQuery and your GA dataset will be there. We'll do a few posts on Google Analytics datasets in Google Data Studio at some point. In the meantime, remember that you now have GA data in a easy to use Data Warehouse, you can move data to other cloud platforms like Azure or AWS, you can use other tools like Tableau and PoweBI to visualise your data, all because it's nice, tidy and safe in BigQuery. Enjoy and if you have anything to add or ask hit us up in the comments.

Remember to check out the How-To section of our blog for more tutorials.

recent projects