Skip to content
Datasets / Website Analytics
Dataset

Website Analytics SQL Practice Dataset

Sessions, pageviews, events, users, and campaigns for funnel and attribution practice.

Tables
5
Rows
161
Size
Small
Level
Intermediate
Domain
Marketing
Formats
CSV · SQL

Download this dataset, free

No account, no email, no attribution required: dedicated to the public domain under CC0 1.0, so commercial use and redistribution are fine. Open it in the browser playground, take the single website_analytics.sql file to load every table into PostgreSQL, MySQL, SQLite, DuckDB, or SQL Server, or grab the raw CSV files below.

website_analytics.sql All 5 tables, 161 rows, as CREATE TABLE and INSERT statements. Download →

Website Analytics models a small SaaS marketing site. It includes sessions, pageviews, funnel events, known users, and campaign metadata, so it is built for SQL questions about traffic quality, conversion, content performance, and attribution.

The data intentionally mixes anonymous and known sessions, direct and campaign traffic, repeated pageviews, and events that only appear for some sessions. That makes it a good fit for practicing COUNT DISTINCT, rates, left joins, and null-aware filters.

Schema

How the Website Analytics tables join userscampaignssessionspageviewsevents user_idcampaign_idsession_iduser_idcampaign_idpageview_idsession_idevent_idsession_id PKPKPKFKFKPKFKPKFK + 5 more columns+ 4 more columns+ 4 more columns+ 2 more columns+ 2 more columns
Arrows point from a column to the key it references. PK marks a table's key and FK a column that references another table.
Join conditions
  • sessions.user_id = users.user_id
  • sessions.campaign_id = campaigns.campaign_id
  • pageviews.session_id = sessions.session_id
  • events.session_id = sessions.session_id
Schema · Website Analytics View dataset schema 5 tables
Table · users

One row per known (signed-up) user.

6 columns · 12 rows
user_id int first_name text last_name text signup_date date country text plan text
Table · campaigns

Marketing campaigns with their channel and UTM tags.

5 columns · 5 rows
campaign_id int campaign_name text channel text utm_source text utm_medium text
Table · sessions

One row per visit. Anonymous visits have a null user_id; organic and direct visits have a null campaign_id.

7 columns · 30 rows
session_id int user_id int session_date date channel text campaign_id int device text duration_seconds int
Table · pageviews

One row per page viewed within a session, in view_order.

4 columns · 75 rows
pageview_id int session_id int path text view_order int
Table · events

Funnel events (signup, add_to_cart, checkout, purchase). Only purchase events carry a value.

4 columns · 39 rows
event_id int session_id int event_name text value decimal

Best for

  • COUNT DISTINCT, conversion rates, and funnel reports.
  • LEFT JOIN attribution from sessions to campaigns.
  • NULL handling for anonymous users and uncampaigned traffic.

Starter questions

  • Which channels drive the highest purchase rate?
  • Which pages are viewed most often?
  • How many sessions are anonymous?

Practice lessons