-
Implementing Multiple Filters for GA4 Event Parameters in BigQuery
Hey there, data whiz! So, I’ve got this GA4 thingy data sitting in BigQuery and I’ve got a bit of a brain-twister on my hands. I know – rejoice, right! – I can use unnest to pick some values from the event_params. But, I’m scratching my head here trying to figure out how to sift out based on multiple values, like for example, dimensions, at the same time. My case in point is I’ve got these two dimensions called page_path and previous_page_path. No sweat, I can scoop them up separately, like so:
SELECT (SELECT value.string_value FROM UNNEST(event_params) WHERE key = 'page_path') AS page_path, (SELECT value.string_value FROM UNNEST(event_params) WHERE key = 'previous_page_path') AS previous_page_path, FROM
project.dataset.events_<span class="hljs-operator">*</span>
Now here’s the kicker – when I attempt to bring in a Where to add more filtering to the mix, those darn alias names don’t fly and BigQuery gives me an error. Like for instance, when I tried this it hiccuped:
SELECT (SELECT value.string_value FROM UNNEST(event_params) WHERE key = 'page_path') AS page_path, (SELECT value.string_value FROM UNNEST(event_params) WHERE key = 'previous_page_path') AS previous_page_path, FROM
project.dataset.events_<span class="hljs-operator">*</span>
WHERE page_path = "/"I’m sure there’s a way to crack it, but got no clue. You wouldn’t know how to do this, would you?
Alright, the end game is I wanna be able to sift out multiple event_params. I think it’s gonna involve multiple unnesting steps since key can’t hold two values at once. But, I’m stuck on how the query should look to pull this off. Any clues?
Log in to reply.