Building blocks
Segments
Segments are made up of conditions against various attributes. They are the groups of users that you can target.
Create a segment
Let's assume we already have two attributes:
country
: accepting country codes likeus
for United States, anddevice
: accepting device name likeiPhone
oriPad
Now, let's say we want to create a segment for targeting all iPhone users in the United States in our application.
We can do that by creating a segment:
# segments/iPhoneUS.yml
description: iPhone users in the United States
conditions:
- attribute: country
operator: equals
value: us
- attribute: device
operator: equals
value: iPhone
Operators
These operators are supported as conditions:
Operator | Type of attribute | Description |
---|---|---|
equals | any | Equals to |
notEquals | any | Not equals to |
greaterThan | integer , double | Greater than |
greaterThanOrEquals | integer , double | Greater than or equal to |
lessThan | integer , double | Less than |
lessThanOrEquals | integer , double | Less than or equal to |
contains | string | Contains string |
notContains | string | Does not contain string |
startsWith | string | Starts with string |
endsWith | string | Ends with string |
in | string | In array of strings |
notIn | string | Not in array of strings |
before | string , date | Date comparison |
after | string , date | Date comparison |
semverEquals | string | Semver equals to |
semverNotEquals | string | Semver not equals to |
semverGreaterThan | string | Semver greater than |
semverGreaterThanOrEquals | string | Semver greater than or equals |
semverLessThan | string | Semver less than |
semverLessThanOrEquals | string | Semver less than or equals |
Examples of each operator below:
equals
# ...
conditions:
- attribute: country
operator: equals
value: us
notEquals
# ...
conditions:
- attribute: country
operator: notEquals
value: us
greaterThan
# ...
conditions:
- attribute: age
operator: greaterThan
value: 21
greaterThanOrEquals
# ...
conditions:
- attribute: age
operator: greaterThanOrEquals
value: 18
lessThan
# ...
conditions:
- attribute: age
operator: lessThan
value: 65
lessThanOrEquals
# ...
conditions:
- attribute: age
operator: lessThanOrEquals
value: 64
contains
# ...
conditions:
- attribute: name
operator: contains
value: John
notContains
# ...
conditions:
- attribute: name
operator: notContains
value: Smith
startsWith
# ...
conditions:
- attribute: name
operator: startsWith
value: John
endsWith
# ...
conditions:
- attribute: name
operator: endsWith
value: Smith
in
# ...
conditions:
- attribute: country
operator: in
value:
- be
- nl
- lu
notIn
# ...
conditions:
- attribute: country
operator: notIn
value:
- fr
- gb
- de
before
# ...
conditions:
- attribute: date
operator: before
value: 2023-12-25T00:00:00Z
after
# ...
conditions:
- attribute: date
operator: after
value: 2023-12-25T00:00:00Z
semverEquals
# ...
conditions:
- attribute: version
operator: semverEquals
value: 1.0.0
semverNotEquals
# ...
conditions:
- attribute: version
operator: semverNotEquals
value: 1.0.0
semverGreaterThan
# ...
conditions:
- attribute: version
operator: semverGreaterThan
value: 1.0.0
semverGreaterThanOrEquals
# ...
conditions:
- attribute: version
operator: semverGreaterThanOrEquals
value: 1.0.0
semverLessThan
# ...
conditions:
- attribute: version
operator: semverLessThan
value: 1.0.0
semverLessThanOrEquals
# ...
conditions:
- attribute: version
operator: semverLessThanOrEquals
value: 1.0.0
Conditions
Conditions can also be combined using and
, or
, and not
operators.
and
# ...
conditions:
and:
- attribute: country
operator: equals
value: us
- attribute: device
operator: equals
value: iPhone
or
# ...
conditions:
or:
- attribute: country
operator: equals
value: us
- attribute: country
operator: equals
value: ca
not
# ...
conditions:
not:
- attribute: country
operator: equals
value: us
Complex
and
and or
can be combined to create complex conditions:
# ...
conditions:
- and:
- attribute: device
operator: equals
value: iPhone
- or:
- attribute: country
operator: equals
value: us
- attribute: country
operator: equals
value: ca
You can also nest and
, or
, and not
operators:
# ...
conditions:
- not:
- or:
- attribute: country
operator: equals
value: us
- attribute: country
operator: equals
value: ca
Archiving
You can archive a segment by setting archived: true
:
# segments/iPhoneUS.yml
archived: true
description: iPhone users in the United States
conditions:
- attribute: country
operator: equals
value: us
- attribute: device
operator: equals
value: iPhone