Make the offer while they are comparing plans
A user has opened the premium plan screen three times this week and closed it each time without upgrading. The upsell campaign runs on its own calendar, so its next push lands days after this week's comparing has stopped, or before it started. The decision is being made now, on the screen they keep coming back to. The offer belongs there, and it should name the plan they have compared most.
plan_screen_views_7d- Times the premium plan screen was opened in the last seven days
top_plan_viewed_7d- The plan they opened most on that screen in the last seven days
Shows the offer on the plan screen once a basic user has opened it three times in a week, and puts the plan they keep comparing at the top. Your billing system says they are still on the basic plan. Signals supplies what they have been looking at.
from datetime import timedelta
from snowplow_signals import Attribute, Event, EventProperty, StreamAttributeGroup, user_id
plan_screen_viewed = Event(name="plan_screen_viewed", vendor="com.example", version="1-0-0")
plan_screen_views_7d = Attribute(
name="plan_screen_views_7d",
type="int32",
events=[plan_screen_viewed],
aggregation="counter",
period=timedelta(days=7),
default_value=0,
)
top_plan_viewed_7d = Attribute(
name="top_plan_viewed_7d",
type="string",
events=[plan_screen_viewed],
aggregation="most_frequent",
property=EventProperty(vendor="com.example", name="plan_screen_viewed", major_version=1, path="plan"),
period=timedelta(days=7),
)
# Users are signed in to the app, so this group keys on the user id.
fit_upgrades_deciding = StreamAttributeGroup(
name="fit_upgrades_deciding",
version=1,
attribute_key=user_id,
owner="you@example.com",
attributes=[plan_screen_views_7d, top_plan_viewed_7d],
)// In the code that renders the premium plan screen
const user = await signals.getServiceAttributes({
name: "fit_upgrades_deciding",
attribute_key: "user_id",
identifier: userId,
});
// { plan_screen_views_7d: 3, top_plan_viewed_7d: "premium_annual" }
if (account.plan === "basic" && user.plan_screen_views_7d >= 3) {
offer.show({
plan: user.top_plan_viewed_7d,
placement: "plan_screen",
headline: "The plan you keep coming back to",
});
}