Skip to main content

GA4 | dimensions & metrics

Events dimensions, parameters & metrics (GA4)

How to query the most important events dimensions and metrics from the GA4 BigQuery export, like event date, timestamp, event name, event parameter key and different values: string, integer, float and double.

A lot of Google Analytics 4 dimensions and metrics can be derived straight from the tables without performing calculations on the data. With the help of unnest and parse for dates or timestamps we can do the trick.

Other dimensions and metrics that you might need are a bit harder to access. You will have to (re)calculate them, which can require some serious SQL-skills.

While designing the course Query GA4 Data In Google BigQuery I've learned a lot about best practices to calculate dimensions and metrics. To share this knowledge with you I will provide a combined query for default dimensions and metrics, and a single example query for every non-default dimension or metric.

As always, drop a line in the comments if you have any questions, feedback or suggestions related to this article.

Default event dimensions

  • event_date
  • event_timestamp
  • event_name
  • event_params.key
  • event_previous_timestamp
  • event_bundle_sequence_id
  • event_server_timestamp_offset
  • event_dimensions.hostname
  • batch_page_id (available from 2024-07-11)
  • batch_ordering_id (available from 2024-07-11)
  • batch_event_index (available from 2024-07-11)

Event parameters

  • event_params.key
  • event_params.value.string_value
  • event_params.value.int_value
  • event_params.value.float_value
  • event_params.value.double_value

Default event metrics

  • event_value_in_usd
💡
If you only need one default dimension or metric, look at the -- comments in the example query below for names and definitions and copy the part you need from the select clause. Make sure that you also add any additional conditions (i.e. with, from, where, group by, having and order by) that are necessary to calculate the results correctly. E.g, the query below is ungrouped, so every row corresponds to an event and may contain duplicate rows.

Example query

select
    -- event_date (dimension | the date on which the event was logged)
    parse_date('%Y%m%d',event_date) as event_date,
    -- event_timestamp (dimension | the time (in microseconds, utc) at which
    -- the event was logged on the client)
    timestamp_micros(event_timestamp) as event_timestamp,
    -- event_name (dimension | the name of the event)
    event_name,
    -- event_key (dimension | the event parameter's key | change key to select another parameter)
    (select key from unnest(event_params) where key = 'page_location') as event_key,
    -- event_string_value (dimension | the string value of the event parameter | change key to select another parameter)
    (select value.string_value from unnest(event_params) where key = 'page_location') as event_string_value,
    -- event_int_value (mdimension | the integer value of the event parameter | change key to select another parameter)
    (select value.int_value from unnest(event_params) where key = 'ga_session_id') as event_int_value,
    -- event_float_value (dimension | the float value of the event parameter | change key to select another parameter)
    (select value.float_value from unnest(event_params) where key = 'page_location') as event_float_value,
    -- event_double_value (dimension | the double value of the event parameter | change key to select another parameter)
    (select value.double_value from unnest(event_params) where key = 'page_location') as event_double_value,
    -- event_previous_timestamp (dimension | the time (in microseconds, utc) at which the event was previously logged on the client)
    timestamp_micros(event_previous_timestamp) as event_previous_timestamp,
    -- event_value_in_usd (metric | the currency-converted value (in usd) of the event's "value" parameter)
    event_value_in_usd,
    -- event_bundle_sequence_id (dimension | the sequential id of the bundle in which these events were uploaded)
    event_bundle_sequence_id,
    -- event_server_timestamp_offset (dimension | timestamp offset between collection time and upload time in micros)
    event_server_timestamp_offset,
    -- event_dimensions.hostname (dimension | hostname)
    event_dimensions.hostname,
    -- batch_page_id (dimension | a sequential number assigned to a page that increases for each subsequent page within an engagement)
    batch_page_id,
    -- batch_ordering_id (dimension | a monotonically increasing number that is incremented each time a network request is sent from a given page)
    batch_ordering_id,
    -- batch_event_index (dimension | a number indicating the sequential order of each event within a batch based on their order of occurrence on the device)
    batch_event_index
from
    -- change this to your google analytics 4 export location in bigquery
    `ga4bigquery.analytics_250794857.events_*`
where
    -- change event_name to select another event
    event_name = 'page_view'
    -- define static and/or dynamic start and end date
    and _table_suffix between '20240701'
    and format_date('%Y%m%d',date_sub(current_date(), interval 1 day))