Skip to Content
OverviewState in ResultFly

State in ResultFly

1. What Is State in ResultFly

State is the set of data points the campaign logic can read and update while a user interacts with ResultFly experiences. It powers conditions and branching, drives calculations and limits, and stores user progress across steps. State evolves as the campaign runs, capturing every decision the system makes on behalf of the participant.

2. System State vs Business State

System State is managed entirely by ResultFly. It covers items such as state.sessionId, the current step or screen, and time-based context. Campaign authors cannot modify System State, and it exists to keep the runtime stable.

Business State is what campaign teams design. It consists of the declared variables that fuel promotions—points, tiers, flags, counters, and any other business-driven values. Business State is the portion of State that marketers model and control.

ResultFly keeps these layers separate so operational data never conflicts with campaign logic.

3. Variable Scopes

Declared variables live in clear scopes, which define how widely the value is shared:

  • User scope (state.user.*) — data that follows the person across campaigns, channels, and sessions (for example lifetime loyalty points).
  • Campaign scope (state.campaign.*) — values specific to a single campaign, reused across its apps and nodes.
  • App scope (state.app.*) — data tied to an individual app or game inside the campaign, typically reset when the participant restarts that experience.

These scopes explain how information travels without exposing storage internals.

4. Declared Variables

Every value used by campaign logic must be declared before launch. The declaration defines the variable name, its scope (user, campaign, or app), and reserves a slot inside State. ResultFly limits the number of declared variables per scope (for example up to ten) to keep campaigns predictable, prevent silent typos, and control data growth.

Declaring variables upfront brings several benefits:

  • Reduces mistakes by catching unexpected names during configuration.
  • Makes the logic easy to audit and communicate across teams.
  • Keeps analytics and segmentation focused on known fields.
  • Avoids runaway storage of unused data.

5. Naming and Structure of Variables

Use descriptive names that reflect the business meaning:

  • state.user.loyalty_points
  • state.user.daily_attempts
  • state.campaign.tier
  • state.app.round_score

ResultFly does not impose semantics on these names. The campaign defines how and when values change; ResultFly enforces that the same names are used consistently.

6. How State Changes During a Campaign

  1. A user opens an app or game.
  2. ResultFly initializes State with the declared variables and current values.
  3. The campaign reads those values to decide which step or reward comes next.
  4. As the participant interacts, nodes update the relevant variables.
  5. The updated State feeds into subsequent decisions in the same session or later visits.

This cycle repeats across campaigns, ensuring that business rules always act on declared data.

7. Session and Cross-Session Behavior

Variables can be read at the start of every session, modified mid-flow, and revisited later. Whether a value persists between sessions depends on its scope and the campaign’s logic—for example, state.user.* typically remains across sessions, whereas state.app.* might reset when the app restarts. Campaign creators describe the intended behavior when they declare the variable and design the flow.

8. What You Cannot Do with State

  • You cannot create variables on the fly.
  • You cannot edit or reuse System State fields.
  • You cannot read or write undeclared variables.
  • You cannot use State as an arbitrary data dump; only the declared business values belong there.

9. Relationship to Other Concepts

State is the language campaigns use to make decisions. External Events can update State even when the user is offline, and identity logic ensures the right record receives those updates. Rewards, access to steps, and personalized flows all depend on State being well-modeled ahead of time.

By treating State as a declared, structured tree, ResultFly gives marketing teams freedom to model their businesses without losing control over data quality or campaign predictability.

Last updated on