Conversion between each funnel step
The task
The shopping app has a four step funnel, in this order:
view_itemadd_to_cartbegin_checkoutpurchase
A user is counted at a step when they have fired that step's event at least once and have also fired the events of every earlier step. The order of the events in time does not matter for this question, and the sessions do not have to match.
Return one row per step (four rows):
step_number: 1 to 4step: the event nameusers: how many users are counted at that steppct_of_previous:usersas a percentage of the users at the step before, rounded to 1 decimal place. For step 1 use 100.0. NULL when the step before has no users.pct_of_first:usersas a percentage of the users at step 1, rounded to 1 decimal place. NULL when step 1 has no users.
Sort by step_number.
Expected output
step_numberstepuserspct_of_previouspct_of_first- Sorted by step_number ascending.
- Numbers rounded to 1 decimal place.
- Checked on the sample and on 3 hidden datasets. How grading works
Tables Mobile shopping app · click a name to insert it
users360 rows in the sample
One row per user. Key: user_id.
| int | Unique id. | |
| timestamp | Sign-up time (UTC). | |
| text | Two-letter country code. | |
| text | ios, android or web. | |
| text | organic, paid, referral or partner. NULL when unknown. |
events7,616 rows in the sample
One row per tracked event. Key: event_id.
| bigint | Unique id. | |
| int | Who fired it. | |
| text | app_open, search, view_item, add_to_cart, begin_checkout, purchase or share. | |
| timestamp | When (UTC). | |
| text | Session the event belongs to. NULL for a few events sent from the background. | |
| numeric(10,2) | Order value for purchase events, NULL otherwise. |
experiment_assignments349 rows in the sample
Which variant each user saw in each experiment. Key: user_id, experiment.
| int | The user. | |
| text | new_onboarding or one_tap_checkout. | |
| text | control or treatment. | |
| timestamp | When the user was assigned (UTC). |
Related questions
Loading the editor and PostgreSQL
Loading the editor and PostgreSQL