Skip to main content

UA | Universal Analytics

User: dimensions & metrics

The most important user dimensions and metrics for GA360 BigQuery export, like user type and users.

💡
This article is about GA3 - Universal Analytics

This example query contains all following Google Analytics user 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.

User dimensions

  • user type
  • count of sessions

User metrics

  • users
  • new users
  • % new sessions
  • number of sessions per user
  • hits

Example query

select
  -- user type (dimension)
  case when totals.newvisits = 1 then 'New visitor' else 'Returning visitor' end as user_type,
  -- count of sessions (dimension)
  visitnumber as count_of_sessions,
  -- users (metric)
  count(distinct fullvisitorid) as users,
  -- new users (metric)
  count(distinct(case when totals.newvisits = 1 then fullvisitorid else null end)) as new_users,
  -- % new sessions (metric)
  count(distinct(case when totals.newvisits = 1 then fullvisitorid else null end)) / count(distinct concat(fullvisitorid, cast(visitstarttime as string))) as percentage_new_sessions,
  -- number of sessions per user (metric)
  count(distinct concat(fullvisitorid, cast(visitstarttime as string))) / count(distinct fullvisitorid) as number_of_sessions_per_user,
  -- hits (metric)
  sum((select totals.hits from unnest(hits) group by totals.hits)) as hits
from
  `bigquery-public-data.google_analytics_sample.ga_sessions_20160801`
group by
  user_type,
  count_of_sessions
order by
  count_of_sessions