Learn business growth with Google Analytics 4 Forums Google Analytics 4 Troubleshooting Query for Obtaining 2 String Values in Google BigQuery Reply To: Troubleshooting Query for Obtaining 2 String Values in Google BigQuery

  • Emma

    Member
    3 September 2022 at 12:55 pm

    It appears that you’re trying to unnest the same field ‘event_params’ twice in your query, which may contribute to the issue. If you’re instead trying to leverage information within the ‘event_params’ field, you can select these details after the unnest operation. Here’s an example of how you might structure your query, assuming each ‘listing’ event only has one ‘product_id’:

    SELECT
    params.key as product_id,
    COUNT(*) as share
    FROM
    dataset,
    UNNEST(event_params) as params
    WHERE
    event_name = ‘listing’
    AND params.key = ‘product_id’
    GROUP BY
    product_id

    In this query, ‘dataset’ should be replaced by your actual dataset and table names. The unnest operation ‘flattens’ the ‘event_params’. Following this, you filter events by ‘listing’ and aggregate by the ‘product_id’ key. The result will be the count of each product_id in ‘listing’ events.