Open on the first workout, not the goal screen again
A new user installed the app yesterday, picked a goal and closed it before starting a workout. Today they open it to the home screen everyone gets, with the goal flow waiting to be redone and a feed with nothing in it yet. The opening screen is set once per release, so what a user did last time reaches it in the next report, after this user has decided whether to come back. The step this user has not done is the first workout, and the app can know that the moment it opens.
onboarding_step_reached- The last setup step they completed
workouts_completed_7d- Workouts finished in the last seven days
days_since_first_open- Days since they first opened the app
Opens on the first workout for a user in their first week whose last completed step was the goal and who has no finished workout yet, and skips the goal flow they have been through.
from datetime import timedelta
from snowplow_signals import Attribute, Event, EventProperty, StreamAttributeGroup, user_id
app_opened = Event(name="app_opened", vendor="com.example", version="1-0-0")
step_completed = Event(name="onboarding_step_completed", vendor="com.example", version="1-0-0")
workout_completed = Event(name="workout_completed", vendor="com.example", version="1-0-0")
onboarding_step_reached = Attribute(
name="onboarding_step_reached",
type="string",
events=[step_completed],
aggregation="last",
property=EventProperty(vendor="com.example", name="onboarding_step_completed", major_version=1, path="step"),
)
workouts_completed_7d = Attribute(
name="workouts_completed_7d",
type="int32",
events=[workout_completed],
aggregation="counter",
period=timedelta(days=7),
default_value=0,
)
days_since_first_open = Attribute(
name="days_since_first_open",
type="double",
events=[app_opened],
aggregation="time_since_first",
time_unit="d",
)
# Users sign in on first open, so the user id is the key from the first event on.
fit_onboarding_goal = StreamAttributeGroup(
name="fit_onboarding_goal",
version=1,
attribute_key=user_id,
owner="you@example.com",
attributes=[onboarding_step_reached, workouts_completed_7d, days_since_first_open],
)// In the code that picks the screen the app opens on
const user = await signals.getServiceAttributes({
name: "fit_onboarding_goal",
attribute_key: "user_id",
identifier: userId,
});
// { onboarding_step_reached: "goal_set", workouts_completed_7d: 0, days_since_first_open: 1.1 }
if (
user.onboarding_step_reached === "goal_set" &&
user.workouts_completed_7d === 0 &&
user.days_since_first_open <= 7
) {
app.openOn({ screen: "first_workout" });
}