Define and Analyze Early Engagement
ChimeData Scientist · Technical ScreenLast updated
Define an early user activation metric for a fintech platform, write a SQL query to measure monthly cohort activation rates across acquisition channels, and account for lifecycle maturity bias.
Scenario
In consumer digital banking, a user who signs up but never funds or uses their account provides little long-term value. Product teams frequently track an early engagement (activation) metric to evaluate onboarding health and acquisition channel quality.
Define an "activated user" as a user who completes at least 3 successful debit transactions totaling at least $50.00 within their first 30 days of registration (inclusive of day 0 through day 30).
Database Schema
users
| Column | Type | Description |
|---|---|---|
user_id | INT | Primary key |
signup_date | DATE | Date the user opened their account |
acquisition_channel | VARCHAR | Marketing channel (e.g., 'organic', 'paid_search', 'referral') |
transactions
| Column | Type | Description |
|---|---|---|
transaction_id | INT | Primary key |
user_id | INT | Foreign key to users.user_id |
transaction_date | DATE | Date of the transaction |
transaction_type | VARCHAR | Type: 'debit', 'deposit', 'transfer' |
status | VARCHAR | Status: 'completed', 'pending', 'declined', 'reversed' |
amount | DECIMAL(10, 2) | Transaction amount in USD (positive value) |
Task
Write a SQL query that produces a monthly cohort report showing activation performance by acquisition channel.
Your query should return:
cohort_month: First day of the signup month formatted as'YYYY-MM-01'.acquisition_channel: The acquisition channel name.total_users: Total number of users registered in that cohort and channel.activated_users: Total number of users who met the activation criteria within 30 days of signup.activation_rate_pct: Percentage of users activated, rounded to 2 decimal places (activated_users * 100.0 / total_users).
Constraints & Edge Cases
- Only consider transactions where
status = 'completed'andtransaction_type = 'debit'. - Transactions must occur between
signup_dateandsignup_date + INTERVAL '30 days'(inclusive). - Exclude users who signed up within the last 30 days relative to
CURRENT_DATEto prevent maturity bias (incomplete observation window). - Order results by
cohort_monthASC, thenacquisition_channelASC.
Example Output
cohort_month | acquisition_channel | total_users | activated_users | activation_rate_pct
-------------+---------------------+-------------+-----------------+--------------------
2023-01-01 | organic | 1200 | 480 | 40.00
2023-01-01 | paid_search | 2500 | 750 | 30.00
2023-01-01 | referral | 800 | 440 | 55.00
2023-02-01 | organic | 1350 | 567 | 42.00
Hints
Hint 1
Filter out users whose signup date is within 30 days of CURRENT_DATE early to prevent immature cohorts from skewing activation rates downwards.
Hint 2
Join transactions on both user_id and a date condition that restricts transaction_date to between signup_date and signup_date + INTERVAL '30 days'.
Hint 3
Use a subquery or CTE to aggregate user-level transaction count and spend before joining back to the cohort table, or use conditional aggregation with user-level grouping.
Follow-up questions
- How would you handle or model users who signed up fewer than 30 days ago if product managers need real-time, weekly visibility without waiting a full month?
- If referral cohorts show a 55% activation rate compared to 30% for paid search, how would you design an experiment or observational study to verify whether referrals causally drive higher retention versus self-selection?
- How would you optimize this query to run efficiently if the transactions table has 500 million rows partitioned by transaction_date?
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.