Filters are a powerful tool for segmenting your player base into distinct audiences based upon any desired criteria using the default, computed, and custom properties.
Filter expressions can use any combination of the following:
- String - A string of characters enclosed in double or single quotes. For example
- Number - A number, for example
123. Digit separators can be used to improve readability. For example
- Boolean - A boolean value, either
- Array - A list of values enclosed in square brackets. For example
[1, 2, 3].
- Map - A list of key-value pairs enclosed in curly braces. For example
- Nil - The absence of a value, represented by the keyword
The following operators are available for use in filter expressions:
|Not equal to|
|Less than or equal to|
|Greater than or equal to|
PropertiesCustom("firstName", "John") + " " + PropertiesCustom("lastName", "Doe")
|Regular expression match|
Properties("countryCode", "US") matches "US||CA||GB"
|String contains substring|
Properties("email", "") contains "heroic"
|String starts with substring|
PropertiesCustom("installVersion", "1.0.0") startsWith "2.0.0"
|String ends with substring|
Properties("email", "") endsWith "@heroiclabs.com"
Functions can be used in your filter expressions to perform more complex operations, and are called using the
() syntax. The following functions are available:
|Returns the current time in seconds since epoch.|
|Returns a duration in seconds.|
Properties(string, object): object
|Returns the properties of an identity, or default value.|
PropertiesComputed(string, object): object
|Returns the computed properties of an identity, or default value.|
PropertiesCustom(string, object): object
|Returns the custom properties of an identity, or default value.|
The following examples demonstrate the use of filter expressions to create custom audiences.
Now() - updateTime < Duration("30d")
|All identities that have been updated in the last 30 days.|
Now() - createTime <= Duration("2d")
|All identities that have been created in the last 2 days.|
Now() - updateTime < Duration("2d")
|All identities with a play session in the last 2 days.|
Now() - updateTime > Duration("7d") and Now() - updateTime < Duration("14d")
|All identities with a last play session between 7 and 14 days ago.|
Now() - updateTime >= Duration("14d")
|All identities with a last play session more than 14 days ago, an so have likely churned.|
PropertiesComputed("sessionStartCount", 0) >= 100
|All identities with 100 or more play sessions.|
PropertiesComputed("purchaseCompletedCount", 0) > 0
|All identities that have made at least one purchase.|
PropertiesComputed("purchaseCompletedCount", 0) < 1
|All identities that have not made any purchases.|
Now() - PropertiesComputed("purchaseCompletedSeenLast", 0) < Duration("7d") and PropertiesComputed("purchaseCompletedCount", 0) > 0
|All identities that have made a purchase in the last 7 days.|
PropertiesComputed("levelCompleted", 0) >= 10
|All identities that have reached level 10 or higher. Assumes a |
levelCompleted event has been created.