LogoStacked
Concepts

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:

  1. Trigger Event → 2. Call Context → 3. Instant Evaluation → 4. Surface Offers → 5. Send Notification

Common Context Patterns

Commerce

Shopping moments

  • shop_open - User enters shop
  • browse_weapons - Viewing category
  • cart_abandon - Leaves without buying

Offers: Purchase bonuses, discounts, last-chance deals

Gameplay

Achievement moments

  • level_complete - Finishes level
  • boss_victory - Defeats boss
  • player_death - Fails challenge

Offers: Progress bonuses, victory rewards, revival aids

Resources

Scarcity moments

  • low_energy - Below threshold
  • out_of_currency - Can't afford item
  • inventory_full - No space

Offers: Resource packs, currency packages, storage upgrades

Social

Community moments

  • friend_joined - Friend starts playing
  • guild_event_start - Guild activity begins

Offers: Referral rewards, co-op bonuses, guild specials

Time-Based

Session moments

  • daily_login - User logs in
  • session_ending - About to leave

Offers: Daily rewards, retention incentives

Real-time System

Stacked uses Server-Sent Events (SSE) for instant updates:

Update TypeWhen It HappensWhat Updates
Instant (Real-time)Context triggered, progress made, offer claimableOffers surface, notifications sent, UI updates
On-DemandUser fetches offersComprehensive 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_weapons not just shop
  • Descriptive: level_complete_5 not lc5
  • 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