GA4 (Google Analytics) in Big Query - unnesting.
Anyone have any insights or best practices for un-nesting Google Analytics 4 data inside of Big Query for analysis in Demo? The nested data structure needs to unnesting in tools like Tableau, so wondering if anyone here has connected BigQuery GA4 data to DOMO, and how they are going about it.
Best Answer
-
Bigquery query syntax has methods that allow you to access nested data. Here is their documentation with examples:
For example, say you have a column in a row and the value is a string with nested JSON/Object that looks like this:
Your query in the Domo connector settings would include something that looks like this:
SELECT e.key,e.value.string_value , aa.* FROM ‘your-table’ as aa, UNNEST(even_params) as e WHERE (include whatever condition you want)
And the result would be that those nested values are extracted and become new columns.
1
Answers
-
Bigquery query syntax has methods that allow you to access nested data. Here is their documentation with examples:
For example, say you have a column in a row and the value is a string with nested JSON/Object that looks like this:
Your query in the Domo connector settings would include something that looks like this:
SELECT e.key,e.value.string_value , aa.* FROM ‘your-table’ as aa, UNNEST(even_params) as e WHERE (include whatever condition you want)
And the result would be that those nested values are extracted and become new columns.
1 -
@cpbwg
@rileystahura
The best way to import the full GA4 raw dataset into DOMO is using the Google BigQuery Service Connector (if you've already linked your GA4 account to BQ before and have the export ready - if you haven't done so, then you must use the API with it's limitations).
If you try to import the params or properties without any transformation in the Connector Settings > Query, it will return a format very hard to work with:
[FieldValue{attribute=RECORD, value=[FieldValue{attribute=PRIMITIVE, value= …
As mentioned above, you can UNNEST() the entire column (be aware that's a CROSS JOIN) or a single key into column but if you have a very complex custom implementation that won't be enough.
What I've done in order to work with the Struct REPEATED RECORDS (BigQuery GA4 Schema) in a format that I can use in DOMO was to first parse the Struct into an ARRAY_AGG concatenating every key value, and last using TO_JSON_STRING. The final output is a column with JSON format. What I do last is to use a Python script in the Magic ETL to parse the JSON into single columns. As the implementation I work with has over 50 params and 20 properties (also items), is the best I've figured out.0
Categories
- All Categories
- 1.8K Product Ideas
- 1.8K Ideas Exchange
- 1.6K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 2.9K Transform
- 102 SQL DataFlows
- 626 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 753 Beast Mode
- 61 App Studio
- 41 Variables
- 692 Automate
- 177 Apps
- 456 APIs & Domo Developer
- 49 Workflows
- 10 DomoAI
- 38 Predict
- 16 Jupyter Workspaces
- 22 R & Python Tiles
- 398 Distribute
- 115 Domo Everywhere
- 276 Scheduled Reports
- 7 Software Integrations
- 130 Manage
- 127 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 11 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 110 Community Announcements
- 4.8K Archive