Skip to content

Instantly share code, notes, and snippets.

@jhnvdw
Last active March 20, 2023 12:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save jhnvdw/5bbae7e9a47617b67a8f624668af4469 to your computer and use it in GitHub Desktop.
Save jhnvdw/5bbae7e9a47617b67a8f624668af4469 to your computer and use it in GitHub Desktop.
SELECT
-- geo.continent (dimension | the continent from which events were reported, based on IP address)
geo.continent,
-- geo.sub_continent (dimension | the subcontinent from which events were reported, based on IP address)
geo.sub_continent,
-- geo.country (dimension | the country from which events were reported, based on IP address)
geo.country,
-- geo.region (dimension | the region from which events were reported, based on IP address)
geo.region,
-- geo.city (dimension | the city from which events were reported, based on IP address)
geo.city,
-- geo.metro (dimension | the metro from which events were reported, based on IP address)
geo.metro
FROM
-- Change this to your Google Analytics 4 export location in BigQuery
`ga4.analytics_1234567890.events_*`
WHERE
-- Define static and/or dynamic start and end date
_table_suffix BETWEEN '20200220'
AND FORMAT_DATE('%Y%m%d',DATE_SUB(CURRENT_DATE(), INTERVAL 1 DAY))
GROUP BY
1,
2,
3,
4,
5,
6
LIMIT
10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment