Your question is Clean Motive Event Funnel Data. Start with the requirements and the three tables on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
You are given raw event logs from Motive products and asked to reshape them into a user-day product activity table for analysis. Write a PostgreSQL query that returns one row per user per event date for valid product events only, with the users company name, a cleaned product surface, counts of total valid events and distinct sessions, and a flag showing whether the user triggered a conversion event that day.
Treat view, click, and submit as valid events. Exclude internal users, events with missing user_id, and events whose event_name is null. Map driver_app_home and driver_app_settings to Driver App, fleet_dashboard_overview and fleet_dashboard_reports to Fleet Dashboard, and all other non-null surfaces to Other. A conversion is any valid submit event.
| Column | Type | Description |
|---|---|---|
| user_idPK | INT | Unique user identifier |
| company_id | INT | Company associated with the user |
| user_name | VARCHAR(100) | User display name |
| is_internal | BOOLEAN | Whether the account is internal |
| Column | Type | Description |
|---|---|---|
| company_idPK | INT | Unique company identifier |
| company_name | VARCHAR(100) | Company name |
| Column | Type | Description |
|---|---|---|
| event_idPK | INT | Unique event identifier |
| user_id | INT | User who triggered the event |
| event_time | TIMESTAMP | Timestamp of the event |
| session_id | VARCHAR(50) | Session identifier |
| event_name | VARCHAR(50) | Raw event type |
| product_surface | VARCHAR(100) | Raw product surface name |