Custom dimensions & metrics (UA)
1 min read

Custom dimensions & metrics (UA)

The most important custom dimensions and metrics for GA360 BigQuery export, for different scopes like user, session, hit and product.
Custom dimensions & metrics (UA)

This example query contains all following Google Analytics custom dimensions and metrics. If you only need one dimension or metric, look at the -- comments in the example query and copy the part you need from the select clause. Make sure that you also add any additional conditions (in the from, where, group by and order by) that are necessary to calculate the results correctly.

Custom dimensions

  • custom dimension xx (user)
  • custom dimension xx (session)
  • custom dimension xx (hit)
  • custom dimension xx (product)

Custom metrics

  • custom metric xx value (hit)
  • custom metric xx value (product)

Example query

-- most sample set custom dimensions return null values

select
  -- custom dimension xx (user)
  (select value from unnest(session.customdimensions) where index = 3 group by value) as custom_dimension_xx_user,
  -- custom dimension xx (session)
  (select value from unnest(session.customdimensions) where index = 4 group by value) as custom_dimension_xx_session,
  -- custom dimension xx (hit)
  (select value from unnest(hits.customdimensions) where index = 2 group by value) as custom_dimension_xx_hit,
  -- custom dimension xx (product)
  (select value from unnest(product.customdimensions) where index = 10 group by value) as custom_dimension_xx_product,
  -- custom metric xx (hit)
  sum((select value from unnest(hits.custommetrics) where index = 1)) as custom_metric_xx_hit,
  -- custom metric xx (product)
  sum((select value from unnest(product.custommetrics) where index = 2)) as custom_metric_xx_product
from
  `bigquery-public-data.google_analytics_sample.ga_sessions_20160801` as session,
  unnest(hits) as hits,
  unnest(product) as product
where
  totals.visits = 1
group by
  custom_dimension_xx_user,
  custom_dimension_xx_session,
  custom_dimension_xx_hit,
  custom_dimension_xx_product
order by
  custom_metric_xx_hit desc

Enjoying this post? Subscribe to the GA4BigQuery newsletter!

You will receive regular updates (max 1x/week) straight in your inbox. You can unsubscribe anytime.