How to get BigQuery table name for GA4 queries
When you run SQL on BigQuery, the most important part is to understand what is your table name, so the SQL can work.
Let’s take a look at the BigQuery interface for one of my accounts:
On top of the screen you’ll see the project name, in this case analyticsorgilga4.
Below it, on the data tree on the left side, you can see the project structure:
- BigQuery project name (again) – analyticsorgilga4
- The name of the database – analytics_251579356. By the way, the number 251579356 is the property ID of your Google Analytics account.
- The prefix of the table name – For each day, BigQuery creates a table called events_YYYYMMDD, e.g. events_20230529. Since we usually want to run the query on all the tables, and handle the date range within the query, we usually select events_* which then refers to all tables.
Now that we know the parts of our BigQuery project, we need to construct a full table name to use it in our SQL. The structure goes as follows:
[project name].[database name].events_*
So, in my case, my SELECT will look like this: