Skip to content

Instantly share code, notes, and snippets.

@jhnvdw
Last active March 20, 2023 12:49
Show Gist options
  • Save jhnvdw/c22323e2075b3c0989e1df005e88ca60 to your computer and use it in GitHub Desktop.
Save jhnvdw/c22323e2075b3c0989e1df005e88ca60 to your computer and use it in GitHub Desktop.
SELECT
-- traffic_source.name (dimension | name of the marketing campaign that first acquired the user)
traffic_source.name,
-- traffic_source.medium (dimension | name of the medium (paid search, organic search, email, etc.) that first acquired the user)
traffic_source.medium,
-- traffic_source.source (dimension | name of the network that first acquired the user)
traffic_source.source
FROM
-- Change this to your Google Analytics 4 export location in BigQuery
`ga4.analytics_1234567890.events_*`
WHERE
-- Define static and/or dynamic start and end date
_table_suffix BETWEEN '20200220'
AND FORMAT_DATE('%Y%m%d',DATE_SUB(CURRENT_DATE(), INTERVAL 1 DAY))
GROUP BY
1,
2,
3
LIMIT
10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment