> For the complete documentation index, see [llms.txt](https://docs.criticalmoments.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.criticalmoments.io/conditional-targeting/intro-to-conditions.md).

# Intro to Conditions

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`&#x20;
* Locale: `locale_language_code IN ['en', 'es'] && locale_currency_code == 'USD'`&#x20;
* App info: `versionGreaterThan(app_version, '1.4.2') && app_install_date < date('2021-06-06')`&#x20;
* 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:')`&#x20;

### Properties

Conditions can evaluate over 100 properties:

* [Built in properties](/conditional-targeting/built-in-properties.md): our SDK includes over 100 realtime device conditions from device orientation to "is it raining where the user is". See a [complete list](/conditional-targeting/built-in-properties.md) of built in properties.
* [Custom properties](/conditional-targeting/custom-properties.md): 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.
* [Property history database](/conditional-targeting/conditional-guides/event-and-property-history.md): 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 [date parsing](/conditional-targeting/conditional-guides/working-with-dates.md), [random number generation](/conditional-targeting/syntax-and-operators.md#random-number-generation), [parsing version numbers](/conditional-targeting/syntax-and-operators.md#version-number-operators), URL support (`canOpenURL`), and more.

[Event history](/conditional-targeting/conditional-guides/event-and-property-history.md) 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.&#x20;

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`&#x20;
* 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)

See the [full syntax docs](/conditional-targeting/syntax-and-operators.md) for details.

### Realtime Evaluation

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

### Integration

Conditions are connected to the rest of the system through the [config file](/config-file-structure.md). The following parts of the config file can include an condition strings:

* [Actions](/actions-in-app-messaging/actions-overview.md) and [Triggers](/actions-in-app-messaging/triggers.md) may optionally contain a condition, and only perform the action if the condition is true
* [Conditional actions](/actions-in-app-messaging/conditional-actions.md): are actions which check a condition, and fire one action by name if true, and another if false
* [Feature Flags](/feature-flags/conditional-feature-flags.md) can return their value based on a conditional string, and be updated over time with [remote updates](/config-file-structure.md).
* [Named conditions](/feature-flags/named-conditions-config.md) can evaluate conditions in code. Use them instead of manually writing complex conditional logic in code.
