DIVETEAM
Data reporting dashboard with metrics
SQL
BigQuery
Looker Studio
Reporting & Analysis

Looker Studio + BigQuery + GA4: How to View Multiple Parameters on the Same Event

4 min read
DS_example.png

When using Google Analytics 4 it can be surprisingly difficult to create a table that shows multiple different parameters of the same event as dimensions.

As an example, let’s say that you have a news app, and your authors create content in three categories: “sports”, “politics”, or “fashion”. Every time a user shares an article, you fire an event called “share” with the parameters “content_type” and “content_author”. You might want to pull a table like the example below so that you can view how many shares an author has received in each category.

content_type

content_author

shares

politics

Jen

31

fashion

Bill

27

fashion

Jen

8

The solution to this problem is to use “_UNNEST(event_params)_” for each parameter that you would like to include in your chart.
If you’re familiar with UNNEST you can keep reading, but if this concept is new to you then you’ll want to take a look at my post on How to Flatten a BigQuery Table with UNNEST.


  • Apr 6, 2023


    Updated all references to “data studio” to “looker studio”

Viewing Multiple Parameters on the Same Event in BigQuery

In this BigQuery example, I’ve plugged in the parameters ‘page_location’ and ‘page_title’ so that you can experiment with any dataset containing a web stream, but you can modify these as needed.

Alternatively, if you are selecting a large number of parameters (more than 2) I prefer to use subqueries because they keep the query simple. For example:

Viewing Multiple Parameters on the Same Event in Looker Studio

In Looker Studio, the only way to make this work properly is to use a Custom Query.

Custom Queries

If you’re new to Custom Queries, they are a way of creating a data source from the results of a SQL query, rather than just the raw table that you have sitting in BigQuery (learn more from Google help).

One very cool feature about custom queries is that you can set parameters with them. Parameters are like variables that you can change without modifying your SQL. As an example, you can use parameters to modify the date range, or run the same query on multiple event names. You can even create a chart, copy it, and change the parameters of the duplicate chart so that the same query displays two different charts on the same page of your report.

The steps below show you how to use a custom query with parameters to solve the problem of pulling multiple parameters on the same event in Looker Studio. I’ve also created an Example Looker Studio Report that you can copy and modify.

1. Start by adding a new BigQuery Data Source

2. Copy the following code block

3. In Looker Studio, select “Custom Query”

Paste in the code as shown below. You will need to replace ‘helpful-helper-516.analytics_sample’ with your Google Cloud Platform project ID and dataset ID.

DS-Custom-Query.png

4. Lastly, you will need to enable your parameters

Start by checking the “Enable data parameters” checkbox as shown above. Then create three more parameters like this (you can change the “Default Value” column if needed):

Parameter Name

Parameter ID

Default Value

First Param

first_param

page_referrer

Second Param

second_param

page_location

Evt Name

evt_name

page_view

Once that is saved you can try it out. When you click on the table to edit the data you will notice a new menu where you can enter “Parameters” under “ADD A FILTER”. You can see that your default values are automatically selected, but just type anything in that box to view new parameters or events.

[caption id="" align="alignnone" width="1104"]

Custom query parameters

Custom query parameters [/caption]

Now try to copy this chart and change the parameters to see how flexible this approach is.

Other Resources for BigQuery and GA4

Here are a few other posts that I’ve created for using BigQuery with data from Google Analytics 4:

Insights from the Deep End

Trying to Stay Ahead of the Curve?We Can Help.

The gap between AI-native marketing teams and everyone else is widening. Sign up to receive reports from our team on the front lines as we discuss the tools, tips and techniques that are helping our clients get results.

Follow us on social media:

or subscribe by email
No spam, everUnsubscribe anytimeReal examples only

What You'll Get

Real Results

Case studies from actual campaigns—wins and failures

Quick Takes

New AI tools analyzed for marketing applicability

No Fluff

If it doesn't work, we'll tell you why