Last updated
Analyze website engagement to identify inactive high-engagement customers and understand how many events customers usually take before purchasing.
Analyze website engagement to identify inactive high-engagement customers and understand how many events customers usually take before purchasing.
Your dataset contains one table from a web analytics system: 1. A Web_Events table recording each customer interaction — page views, add-to-cart, checkout, and purchase events — along with the campaign, session, and a JSON field containing event details Note: Some rows have a blank customer_id — exclude these from all queries.
| Column | Type | Key / Notes |
|---|---|---|
| event_id | INT | PK |
| customer_id | VARCHAR(20) | |
| event_date | DATE | |
| event_type | VARCHAR(50) | |
| session_id | VARCHAR(50) | |
| utm_campaign | VARCHAR(50) | |
| event_json | TEXT |
Web_Events — 30 rows
| event_id | customer_id | event_date | event_type | session_id | utm_campaign | event_json |
|---|---|---|---|---|---|---|
| 1 | C001 | 2025-01-05 | page_view | S001 | SummerSale | {"product_id":101} |
| 2 | C001 | 2025-01-06 | add_to_cart | S002 | SummerSale | {"product_id":101} |
| 3 | C001 | 2025-01-07 | checkout | S003 | SummerSale | {"product_id":101} |
| 4 | C001 | 2025-01-08 | Purchase | S004 | SummerSale | {"product_id":101} |
| 5 | C001 | 2025-02-10 | page_view | S005 | SummerSale | {"product_id":102} |
| 6 | C001 | 2025-03-12 | page_view | S006 | SummerSale | {"product_id":103} |
| 7 | C002 | 2025-02-01 | page_view | S007 | FestiveOffer | {"product_id":104} |
| 8 | C002 | 2025-02-02 | add_to_cart | S008 | FestiveOffer | {"product_id":104} |
| 9 | C002 | 2025-02-03 | Purchase | S009 | FestiveOffer | {"product_id":104} |
| 10 | C002 | 2025-08-20 | page_view | S010 | FestiveOffer | {"product_id":105} |
| 11 | C003 | 2025-01-10 | page_view | S011 | NewLaunch | {"product_id":101} |
| 12 | C003 | 2025-01-11 | page_view | S012 | NewLaunch | {"product_id":101} |
| 13 | C003 | 2025-01-12 | add_to_cart | S013 | NewLaunch | {"product_id":101} |
| 14 | C003 | 2025-01-13 | checkout | S014 | NewLaunch | {"product_id":101} |
| 15 | C003 | 2025-01-14 | Purchase | S015 | NewLaunch | {"product_id":101} |
| 16 | C003 | 2025-03-01 | page_view | S016 | NewLaunch | {"product_id":102} |
| 17 | C004 | 2025-04-05 | page_view | S017 | SummerSale | {"product_id":103} |
| 18 | C004 | 2025-04-06 | add_to_cart | S018 | SummerSale | {"product_id":103} |
| 19 | C004 | 2025-04-07 | page_view | S019 | SummerSale | {"product_id":103} |
| 20 | C004 | 2025-04-08 | checkout | S020 | SummerSale | {"product_id":103} |
| 21 | C004 | 2025-04-09 | Purchase | S021 | SummerSale | {"product_id":103} |
| 22 | C004 | 2025-04-10 | page_view | S022 | SummerSale | {"product_id":103} |
| 23 | C005 | 2025-08-01 | page_view | S023 | FestiveOffer | {"product_id":105} |
| 24 | C005 | 2025-08-02 | add_to_cart | S024 | FestiveOffer | {"product_id":105} |
| 25 | C005 | 2025-08-03 | checkout | S025 | FestiveOffer | {"product_id":105} |
| 26 | C005 | 2025-08-04 | Purchase | S026 | FestiveOffer | {"product_id":105} |
| 27 | C006 | 2025-05-01 | page_view | S027 | NewLaunch | {"product_id":106} |
| 28 | C006 | 2025-05-02 | add_to_cart | S028 | NewLaunch | {"product_id":106} |
| 29 | C006 | 2025-05-03 | Purchase | S029 | NewLaunch | {"product_id":106} |
| 30 | 2025-05-04 | page_view | S030 | NewLaunch | {"product_id":106} |
This drill has two questions. Use 2025-09-01 as the reference date. Exclude rows where customer_id is blank. 1. Inactive High-Engagement Customers — Find customers who had more than 5 events on the website in 2025 but no event in the past 45 days (before 2025-09-01). Your result table should have: customer_id. 2. Events Before Purchase — For each customer, find the average number of events they take before making a purchase. Then divide all customers into 4 equal groups using NTILE. Your result table should have: customer_id, avg_events_before_purchase, bukcets.
Your output should look like this (partial example):
| customer_id |
|---|
| C001 |
| C003 |
| … |