Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save madilk/3c58e58c6287ce9c49501bad79b3b0ea to your computer and use it in GitHub Desktop.
Save madilk/3c58e58c6287ce9c49501bad79b3b0ea to your computer and use it in GitHub Desktop.
Big Query & Google Analytics 4 - Query user count where medium matches a parameter

SELECT COUNT (DISTINCT(user_pseudo_id)) AS total_users
FROM your-project-table,
UNNEST (event_params) AS event_param
WHERE event_name = 'page_view'
AND event_param.key = 'medium'
AND event_param.value.string_value = 'organic'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment