Skip to content

Week-two retention by acquisition channel

The task

Marketing wants to compare how well each acquisition channel keeps its users in their second week.

Rules:

  • The sign-up date is day 0 (the UTC date of users.signed_up_at). A user is retained if they fired at least one event on a date from day 7 to day 13, both included.
  • Group users by users.acquisition_channel. Users whose channel is NULL form their own group, labelled unknown.
  • Count users, not events. Users who never fired an event stay in the denominator.

Return channel, users, retained_users and retention_pct (retained users as a percentage of the channel's users, rounded to 1 decimal place). Sort by retention_pct descending, then channel ascending.

Expected output

channelusersretained_usersretention_pct
  • Sorted by retention_pct descending, then channel ascending.
  • Numbers rounded to 1 decimal place.
  • Checked on the sample and on 2 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.

intUnique id.
timestampSign-up time (UTC).
textTwo-letter country code.
textios, android or web.
textorganic, paid, referral or partner. NULL when unknown.
events7,616 rows in the sample

One row per tracked event. Key: event_id.

bigintUnique id.
intWho fired it.
textapp_open, search, view_item, add_to_cart, begin_checkout, purchase or share.
timestampWhen (UTC).
textSession 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.

intThe user.
textnew_onboarding or one_tap_checkout.
textcontrol or treatment.
timestampWhen the user was assigned (UTC).

Related questions

Loading the editor and PostgreSQL