Contexts & Real-time
Triggering instant offers and understanding Stacked's real-time system
What are Contexts?
Contexts are specific moments in your app that trigger instant offer surfacing. When a user enters a context (like opening shop or running low on currency), Stacked immediately surfaces matching offers and sends real-time notifications.
How Contexts Work
Flow:
- Trigger Event → 2. Call Context → 3. Instant Evaluation → 4. Surface Offers → 5. Send Notification
Common Context Patterns
Commerce
Shopping moments
shop_open- User enters shopbrowse_weapons- Viewing categorycart_abandon- Leaves without buying
Offers: Purchase bonuses, discounts, last-chance deals
Gameplay
Achievement moments
level_complete- Finishes levelboss_victory- Defeats bossplayer_death- Fails challenge
Offers: Progress bonuses, victory rewards, revival aids
Resources
Scarcity moments
low_energy- Below thresholdout_of_currency- Can't afford iteminventory_full- No space
Offers: Resource packs, currency packages, storage upgrades
Social
Community moments
friend_joined- Friend starts playingguild_event_start- Guild activity begins
Offers: Referral rewards, co-op bonuses, guild specials
Time-Based
Session moments
daily_login- User logs insession_ending- About to leave
Offers: Daily rewards, retention incentives
Real-time System
Stacked uses Server-Sent Events (SSE) for instant updates:
| Update Type | When It Happens | What Updates |
|---|---|---|
| Instant (Real-time) | Context triggered, progress made, offer claimable | Offers surface, notifications sent, UI updates |
| On-Demand | User fetches offers | Comprehensive evaluation, expired cleanup, new discovery |
Note
Stacked uses a hybrid approach - critical updates happen instantly while comprehensive checks occur on-demand for optimal performance.
Context Naming
Use clear, consistent names for contexts:
- Specific:
shop_open_weaponsnot justshop - Descriptive:
level_complete_5notlc5 - Grouped:
resource_low_energy,resource_low_health - Lowercase with underscores:
achievement_first_win
Best Practices
- Start with 3-5 key contexts - Map user flow, identify decision points and friction moments
- Match context to offer - Low health → Health potions, shop open → Purchase bonuses
- Time contexts well - After achievements (positive mood), during breaks (receptive)
- Respect notification limits - Allow customization, avoid fatigue
- Track performance - Monitor trigger rates, surface rates, completion rates
Stacked