Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nicobrx/364149793ea486c2b9c71bdb1fba65bd to your computer and use it in GitHub Desktop.
Save nicobrx/364149793ea486c2b9c71bdb1fba65bd to your computer and use it in GitHub Desktop.
select
-- day of week, starting with Sunday (dimension)
format_date('%w',parse_date("%Y%m%d",event_date)) as day_of_week,
-- hour (dimension)
format("%02d",extract(hour from timestamp_micros(event_timestamp))) as hour,
(select value.string_value from unnest(event_params) where key = 'page_location') as page_path,
count(event_name) as sessions
from
-- change this to your google analytics 4 export location in bigquery
`yourproject.analytics_1234567.events_*`
where
-- uses dynamic start and end date parameters supported by Looker Studio
_table_suffix between @DS_START_DATE and @DS_END_DATE
and event_name = "session_start"
group by
day_of_week, hour, page_path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment