Learn business growth with Google Analytics 4 Forums Google Analytics 4 Understanding SQL Server parsing of GA4 BigQuery RECORD columns Reply To: Understanding SQL Server parsing of GA4 BigQuery RECORD columns

  • Oliver

    Member
    9 July 2023 at 2:37 am

    Alright! You can use the UNNEST function in BigQuery, which allows you to flatten array data into a table. Here’s an example using the ‘event_params’:

    `
    SELECT
    EP.key AS event_param_key,
    COUNT(*) AS occurrences
    FROM
    — Replace the table name with your table
    bigquery-public-data.ga4_obfuscated_sample_ecommerce.events_*,
    UNNEST(event_params) AS EP
    WHERE
    — Replace with your date range
    _TABLE_SUFFIX BETWEEN ‘20201201’ AND ‘20201202’
    GROUP BY
    event_param_key
    ORDER BY
    event_param_key ASC;
    `

    In this SQL query, each record in the ‘event_params’ array is transformed into a row in the ‘EP’ table, which you can then query as usual.

    For more details, have a look at [this article](https://medium.com/firebase-developers/using-the-unnest-function-in-bigquery-to-analyze-event-parameters-in-analytics-fb828f890b42) which explains how to use the UNNEST function in depth when analyzing event parameters in Analytics.