Write Your First Query

In BigQuery, click on 'Compose Query' . 

In the box on the right you'll see the Query Editor. This is where you type your SQL queries - then press 'Run Query' to see the results. The query will take a few second to run - then the results show below. 

Here are a few example queries to help you get started. Make sure to change 'demo_project'  to your project name. 

Total Pageviews

This query gives the total number of pageview events.

SELECT
COUNT(*)
FROM
demo_project.pageview_events

Total Uniques

This query gives the total number of unique users who have had a pageview.

SELECT
COUNT(DISTINCT(user_id))
FROM
demo_project.pageview_events

Total Sessions

This query gives the total number of sessions.

SELECT
COUNT(DISTINCT(session_id))
FROM
demo_project.pageview_events

Most Popular Cities

This query gives the total pageviews from each city, listed in descending order.

SELECT
properties.geo_info.city as City,
COUNT(*) as Pageviews

FROM
demo_project.pageview_events

GROUP BY City
ORDER BY Pageviews DESC

Top Referrers

This query gives the total pageviews for each referral domain, listed in descending order.

SELECT
DOMAIN(properties.client.referrer) as Referrer,
COUNT(*) as Pageviews

FROM
demo_project.pageview_events

GROUP BY Referrer
ORDER BY Pageviews DESC
Did this answer your question?