How to access a nested field in GA4 BigQuery data table

In this article, you will learn to access a nested field in a GA4 BigQuery export data table.

Consider the following data table:

GA4 BigQuery export data table 2

This data table is for June 18, 2023 which is denoted by 20230618.

Let us suppose you want to query the data which meets the following requirements:

  1. You want to retrieve the data only for June 18, 2023.
  2. You want to retrieve the ‘event_date’ and ‘event_name’ columns of the data table.
  3. You want to see only those rows where ‘event_name’ = ‘page_view’
  4. You want to see the value of ‘page_location’ event parameter as ‘page_location’ column.
  5. You want to retrieve only the first 10 rows of the data table.

Do you want expert help in setting up/fixing GA4 and GTM?

If you are not sure whether your GA4 property is setup correctly or you want expert help migrating to GA4 then contact us. We can fix your website tracking issues.

#1 Use the following text prompt in ‘GA4 BigQuery Composer

Write SQL which meets the following requirements:
1) Show data for June 18, 2023
2) Show only the ‘event_date’ and ‘event_name’ columns of the data table.
3) Show only those rows where the value of ‘event_name’ column is ‘page_view’.
4) Add a new column named ‘page_location’ that contains the value of the ‘page_location’ event parameter. The ‘page_location’ event parameter is an array of structures within the ‘event_params’ array of structures.
5) Show only the first 10 rows of the data table.
My table ID is: dbrt-ga4.analytics_207472454.events_20240416

Note: Use your table ID instead of mine. Otherwise, your SQL code won’t work.

#2 Copy the generated SQL code by clicking on the ‘Copy code’ button:

copy code chatgpt

#3 Paste the copied code in the SQL editor and then click on the ‘Run’ button:

Paste the copied code in the SQL editor ga4 bigquery

Congratulations!

You just created the first meaningful report in BigQuery, where you can see the list of web pages which got views on June 18, 2023.

Consider the following data table:

content group google analytics

This data table is for June 18, 2023 which is denoted by 20230618.

Let us suppose you want to query the data which meets the following requirements:

  1. You want to retrieve the data only for June 18, 2023.
  2. You want to retrieve the ‘event_date’ and ‘event_name’ columns of the data table.
  3. You want to see the value of ‘page_location’ event parameter as ‘page_location’ column.
  4. You want to see the value of ‘content_group’ event parameter as ‘content_group’ column.
  5. You want to see only those rows where ‘content_group’ is ‘Google Analytics’
  6. You want to retrieve only the first 10 rows of the data table.

#1 Use the following text prompt in ‘GA4 BigQuery Composer’

Write SQL which meets the following requirements:
1) Show data for June 18, 2023
2) Show only the 'event_date' and 'event_name' columns of the data table.
3) Add a new column named 'page_location' that contains the values of the 'page_location' event parameter. The 'page_location' event parameter is an array of structures within the 'event_params' array of structures.
4) Add a new column named 'content_group' that contains the values of the 'content_group' event parameter. The 'content_group' event parameter is an array of structures within the 'event_params' array of structures.
5) Show only those rows of the data table where the string value of the ‘content_group’ event parameter is 'Google Analytics'.
6) Show only the first 10 rows of the data table.
My table ID is: dbrt-ga4.analytics_207472454.events_20240416

Note: Use your table ID instead of mine. Otherwise, your SQL code won’t work.

#2 Copy the generated SQL code by clicking on the ‘Copy code’ button:

SQL for retrieving nested field in ga4 bigquery export data table

#3 Paste the copied code in the SQL editor and then click on the ‘Run’ button:

run the SQL for retrieving nested field in ga4 bigquery export data table

My best selling books on Digital Analytics and Conversion Optimization

Maths and Stats for Web Analytics and Conversion Optimization
This expert guide will teach you how to leverage the knowledge of maths and statistics in order to accurately interpret data and take actions, which can quickly improve the bottom-line of your online business.

Master the Essentials of Email Marketing Analytics
This book focuses solely on the ‘analytics’ that power your email marketing optimization program and will help you dramatically reduce your cost per acquisition and increase marketing ROI by tracking the performance of the various KPIs and metrics used for email marketing.

Attribution Modelling in Google Analytics and BeyondSECOND EDITION OUT NOW!
Attribution modelling is the process of determining the most effective marketing channels for investment. This book has been written to help you implement attribution modelling. It will teach you how to leverage the knowledge of attribution modelling in order to allocate marketing budget and understand buying behaviour.

Attribution Modelling in Google Ads and Facebook
This book has been written to help you implement attribution modelling in Google Ads (Google AdWords) and Facebook. It will teach you, how to leverage the knowledge of attribution modelling in order to understand the customer purchasing journey and determine the most effective marketing channels for investment.

About the Author

Himanshu Sharma

  • Founder, OptimizeSmart.com
  • Over 15 years of experience in digital analytics and marketing
  • Author of four best-selling books on digital analytics and conversion optimization
  • Nominated for Digital Analytics Association Awards for Excellence
  • Runs one of the most popular blogs in the world on digital analytics
  • Consultant to countless small and big businesses over the decade