Show the offer on the screen after the workout ends
A trial user has just finished their first workout and is reading the summary. The offer was shown when they first opened the app, before they had done anything in it, and it has not come back since. The moment they have something worth keeping is this one, and the offer belongs on the next screen they see.
minutes_since_workout- Minutes since their last workout ended
workouts_trial- Workouts completed since their first open
Shows the offer on the screen after the summary when a workout ended in the last fifteen minutes, and holds it on every other open so the first screen of the day is not a price.
from datetime import timedelta
from snowplow_signals import Attribute, Event, StreamAttributeGroup, user_id
workout_completed = Event(name="workout_completed", vendor="com.example", version="1-0-0")
minutes_since_workout = Attribute(
name="minutes_since_workout",
type="double",
events=[workout_completed],
aggregation="time_since_last",
time_unit="min",
)
workouts_trial = Attribute(
name="workouts_trial",
type="int32",
events=[workout_completed],
aggregation="counter",
ttl=timedelta(days=30),
default_value=0,
)
# Trial users are signed in, so the group keys on the user id.
fit_paywall_finished = StreamAttributeGroup(
name="fit_paywall_finished",
version=1,
attribute_key=user_id,
owner="you@example.com",
attributes=[minutes_since_workout, workouts_trial],
)// In the code that renders the screen after the workout summary
const user = await signals.getServiceAttributes({
name: "fit_paywall_finished",
attribute_key: "user_id",
identifier: userId,
});
// { minutes_since_workout: 2.4, workouts_trial: 1 }
if (user.minutes_since_workout <= 15 && user.workouts_trial >= 1) {
paywall.show({
plan: "monthly",
headline: "Keep this one in your history",
});
}