On this page

For AI agents: a documentation index is available at /docs/llms.txt. Append .md to any page URL for markdown, or send Accept: text/markdown.

Conditional Logic

Conditional logic evaluates user properties and survey responses to route users through different survey steps or trigger different guide actions. Use it to show different content, branch to different steps, or trigger different actions based on who a user is or what they've answered.

Where you can use conditional logic

Conditional logic works with both guides and surveys. You can select it as an action for either primary or secondary buttons.

Types of conditions

Create conditions based on two types of data:

User properties

User properties are attributes about your users, such as location, subscription tier, or account type. Share user properties client-side during the session with either the Amplitude SDK or the Engagement SDK.

Common user property examples:

  • subscription_tier
  • country
  • account_type
  • initial_referring_domain

User property requirements

Use only properties available client-side during the current session. Amplitude doesn't support properties from prior sessions or properties stored only server-side. Go to Set user properties for implementation details.

Survey responses

Survey responses are the answers users provide to questions in your surveys. Use survey responses to branch your survey based on how users answer. Conditions can reference responses from any prior step in the survey, not just the current one. This lets you build multi-layered branching logic that considers the full context of a user's answers.

Mobile support

Cross-step conditions work on web today. On iOS, Android, React Native, and Flutter, cross-step conditions require a Guides and Surveys mobile SDK release later than 3.13.0, and authoring them for a mobile guide or survey isn't yet available. Until then, mobile conditions can only reference the current step's response.

Survey response examples:

  • NPS ratings
  • Star ratings
  • Single-select list selections
  • Text input values

Multi-select list inputs aren't supported

Amplitude doesn't support conditional logic on multi-select list inputs within the same step or in later steps. In the survey builder, multi-select list questions appear in the Survey Responses dropdown but are disabled. A tooltip explains the limitation. Use a single-select list if you need to branch on the answer. Multi-select conditional logic support is a longer-term follow-up.

Response-based conditions become read-only once the survey receives its first response. Go to Editing conditional logic after launch for details.

Combining conditions

Combine multiple conditions to create more advanced logic. When you add multiple conditions, all conditions must match for the action to execute.

For example: if subscription_tier = premium AND country = US, then visit link to premium US-specific content.

Set up conditional logic

The setup process is similar whether you add conditional logic to buttons or to survey steps.

Add conditional logic to buttons

  1. In your guide or survey, add a primary or secondary button.
  2. Click the On button click dropdown.
  3. Select Evaluate conditional logic.
  4. Navigate to the Conditional Logic section.
  5. Under When, select either User Property or Survey Response from the dropdown.
  6. Configure your condition:
    • For User Property: Select the property, operator, and value.
    • For Survey Response: Select the question, operator, and value. Amplitude doesn't support multi-select list questions here; use a single-select list if you need to branch on the answer.
  7. (Optional) Click Add condition to add more conditions.
  8. Under Do this, select the action to execute when the condition is met.
  9. Configure the action based on your selection.

Multiple conditional actions

Add multiple conditional actions to handle different scenarios. For example, one action for premium users and another for free users. Amplitude evaluates conditions in order and executes the first matching action.

Editing conditional logic after launch

Once a survey receives its first response, its conditional logic becomes read-only. Attempting to edit it shows Can't edit conditional logic after a survey response has been received.

This is intentional: branching determines which respondents saw which steps, so changing it mid-collection makes earlier and later responses non-comparable.

To revise the branching on a live survey, duplicate it, edit the conditional logic on the copy, then publish the copy and unpublish the original. A duplicate starts with no responses, so its conditional logic is fully editable.

Examples and use cases

Branch survey based on NPS score

Create a survey that asks different follow-up questions based on a user's NPS score:

  1. Add an NPS rating block asking "How likely are you to recommend us?"
  2. Add conditional logic:
    • If rating ≤ 6 (Detractors), then go to step asking "What can we improve?"
    • If rating ≥ 9 (Promoters), then go to step saying "Thank you! Would you leave us a review?"

Redirect users based on subscription tier

Create a guide with a button that directs users to different pages based on their subscription level:

  1. Add a primary button labeled "View Features".
  2. Select Evaluate conditional logic.
  3. Add conditions:
    • If subscription_tier = premium, then visit link www.example.com/premium-features.
    • If subscription_tier = free, then visit link www.example.com/upgrade.

Show guide only to specific user segments

Launch a secondary guide based on both user property and survey response:

  1. Add a primary button labeled "Next".
  2. Select Evaluate conditional logic.
  3. Add conditions:
    • If country = US AND rating > 8, then show guide "US-specific-offer".
    • If country ≠ US AND rating > 8, then show guide "international-offer".

Branch based on a prior step's response

Create a survey that uses an earlier step's response to determine a later branch:

  1. Step 1: Add a rating block asking "How satisfied are you with this feature?"
  2. Step 2: Add a multiple choice question asking "Which area needs improvement?"
  3. On step 2, add conditional logic that references the step 1 rating:
    • If step 1 rating ≤ 3, then go to a step asking for detailed feedback about the issue.
    • If step 1 rating ≥ 4, then go to a thank-you step.

This approach lets you combine context from multiple steps to personalize the survey path.

Personalized CTA based on user properties

Create a button action that clicks different elements based on user characteristics:

  1. Add a primary button labeled "Get Started".
  2. Select Evaluate conditional logic.
  3. Add conditions:
    • If user_type = new, then click element [data-testid="onboarding-flow"].
    • If user_type = returning, then click element [data-testid="dashboard"].

Best practices

  • Test thoroughly: Use preview mode to test all conditional paths before publishing.
  • Keep logic simple: Complex nested conditions are difficult to maintain and debug.
  • Monitor results: Use analytics to track how users flow through your conditional experiences.

Was this helpful?