Critical Moments Docs
Quick StartHomepageAccount
  • Documentation Home
  • What is Critical Moments?
  • Quick Start
  • Concepts Overview
  • Remote Control / Service
    • Host Config on Github Pages
  • Config File Structure
  • Demo App
  • Homepage & Account
  • 📚Guides
    • Mobile App Toolbox: 13 Features Most Apps Need
    • Reduce App Churn with Notifications
    • Improve your App Store Rating
    • Feature Flags Guide
  • ⏰Notifications
    • Intro to Notifications
    • Notifications Spec
    • Smart Delivery
    • Badges
  • 🎯Conditional Targeting
    • Intro to Conditions
    • Built-in Properties
    • Custom Properties
    • Syntax and Operators
    • Conditional Guides
      • Working with Dates
      • Locations and Weather
      • Event and Property History
  • 🎪Events
    • Event Overview
    • Recommended Events
    • Built-In Events
  • 💬Actions / In App Messaging
    • Actions Overview
    • Modals
      • Modal Content Sections
      • Modal Buttons
      • Modal Images
    • Banners
    • Alerts
    • App Reviews
    • Open Link
    • Custom Actions
    • Conditional Actions
    • Triggers
  • 🎨Themes
    • Theme Overview
    • Built In Themes
  • ⛳Feature Flags
    • Feature Flag Guide
    • Conditional Feature Flags
    • Named Conditions Config
  • 🔑Trustless SaaS
  • 👋Support
  • 👩‍💻SDK API Reference
Powered by GitBook
On this page
  • Properties
  • Functions
  • Powerful Syntax
  • Realtime Evaluation
  • Integration

Was this helpful?

  1. Conditional Targeting

Intro to Conditions

Powerful conditions for targeting, with over 100 properties

Last updated 1 year ago

Was this helpful?

Conditions are boolean string expressions that can be evaluated with the current state of the users device. A few examples show the range of possiblities:

  • UI State: interface_orientation == 'landscape' || dark_mode || screen_brightness < 0.1

  • Device state: user_interface_idiom == 'tablet' || device_orientation == 'face_up' || device_model_version == '13.3' || device_battery_level > 0.25

  • Locale: locale_language_code IN ['en', 'es'] && locale_currency_code == 'USD'

  • App info: versionGreaterThan(app_version, '1.4.2') && app_install_date < date('2021-06-06')

  • Networking state: network_connection_type != 'cellular' && has_active_network && !low_data_mode && !expensive_network

  • Location: location_approx_city == 'Toronto' || location_region == 'TX'

  • And much more: !on_call && (has_bt_headset || has_wired_headset) && !has_watch && contacts_permission && canOpenUrl('spotify:')

Properties

Conditions can evaluate over 100 properties:

  • : our SDK includes over 100 realtime device conditions from device orientation to "is it raining where the user is". See a of built in properties.

  • : add your own data like "is this a power user" or "date of original account creation". Anything that makes sense for your app or use case.

  • : check the history of any property to see if it has ever held a specific value, when it occurred, or how often it's happened. Allowed for powerful personalized decision making. The database is completely private: data is stored on the user's device, evaluated locally, and never sent off device.

Functions

Conditions allow for inline functions like , , , URL support (canOpenURL), and more.

functions can query the built in database of event history, counting how many times a user has performed an action, or when the last time it was performed.

Powerful Syntax

Conditional expressions support a wide range of operators including order of operation (()), arithmetic (+, -, %, /, *, ^, **), strings (startsWith, endsWith, contains), regex, ranges, and much more.

This powerful set of features can be used to

  • Multi-variable thresholding: device_battery_level > 0.2 && eventCount('app_start') > 5

  • Multi-variable scoring: (eventCount('completed_task_1') * 2) + (eventCount('completed_task_2') * 3) > 15

  • Combine different use cases: for example, a feature flag with progress rollout, while only targeting new iPhones for the initial cohort (exclude iPads and old OSs)

Realtime Evaluation

Conditions are evaluated realtime, and will update their result as device state changes.

Integration

See the for details.

Conditions are connected to the rest of the system through the . The following parts of the config file can include an condition strings:

and may optionally contain a condition, and only perform the action if the condition is true

: are actions which check a condition, and fire one action by name if true, and another if false

can return their value based on a conditional string, and be updated over time with .

can evaluate conditions in code. Use them instead of manually writing complex conditional logic in code.

🎯
Built in properties
complete list
Custom properties
Property history database
date parsing
random number generation
parsing version numbers
Event history
full syntax docs
config file
Actions
Triggers
Conditional actions
Feature Flags
remote updates
Named conditions