You've successfully subscribed to GA4BigQuery
Success! Your account is fully activated, you now have access to all content.
Success! Your billing info is updated.
Billing info update failed.

Traffic sources: dimensions & metrics

Join 2,600+ other professionals and receive a monthly newsletter packed with GA4 & BigQuery news, tips & tricks

Great! Check your inbox and click the link to confirm your subscription
Please enter a valid email address!
Already have an account? Sign in
This article is about GA3 - Universal Analytics

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

Traffic sources dimensions

  • referral path
  • full referrer
  • default channel grouping
  • campaign
  • source
  • medium
  • source / medium
  • keyword
  • ad content
  • social network
  • social source referral
  • campaign code

Traffic sources metrics


Example query

  -- referral path (dimension)
  trafficsource.referralpath as referral_path,
  -- full referrer (dimension)
  concat(trafficsource.source,trafficsource.referralpath) as full_referrer,
  -- default channel grouping
  channelgrouping as default_channel_grouping,
  -- campaign (dimension)
  trafficsource.campaign as campaign,
  -- source (dimension)
  trafficsource.source as source,
  -- medium (dimension)
  trafficsource.medium as medium,
  -- source / medium (dimension)
  concat(trafficsource.source," / ",trafficsource.medium) as source_medium,
  -- keyword (dimension)
  trafficsource.keyword as keyword,
  -- ad content (dimension)
  trafficsource.adcontent as ad_content,
  -- social network (dimension)
  (select social.socialnetwork from unnest(hits) group by social.socialnetwork) as social_network,
  -- social source (dimension)
  (select social.hassocialsourcereferral from unnest(hits) group by social.hassocialsourcereferral) as social_source,
  -- campaign code (dimension)
  trafficsource.campaigncode as campaign_code
  totals.visits = 1