Expressions
In this section, you will learn about Open Loyalty language and more complex campaign conditions.
Introduction to Open Loyalty Language
When setting up conditions and effects for rules in Campaigns, you may find that some situations are not covered by premade values. However, you are not limited to using these values - you can use an Open Loyalty language to create very specific conditions and values. When you click Add condition, you can find a condition called Expression under Popular conditions.


You can set the value of such an expression. It can be set as a combination of attributes and operators using the meta language created by Open Loyalty. It allows you to create a fully customizable condition that meets the rules of your planned loyalty program.
For example, you can create a campaign that is triggered when a customer buys more than one product from a certain category. There is no premade condition for this: filter the items with a rule Target (Add target → attribute), or use an expression:

In the same way, you can create custom campaign effects. Effects are added in the Add effect drawer: under Mode, Standard uses the Applies to, Calculate by and Units fields, and Custom Expression lets you type a formula (e.g. 1*transaction.grossValue):

In this section, you will find a description of the meta-language together with all the supported syntaxes, which is based on the expression syntax of Symfony Expression.
The component supports
strings - single and double quotes (e.g. 'hello')
numbers - integers (e.g. 103), decimals (e.g. 9.95), decimals without leading zeros (e.g. .99, equivalent to 0.99); all numbers support optional underscores as separators to improve readability (e.g. 1_000_000, 3.14159_26535)
arrays - using JSON-like notation (e.g. [1, 2])
hashes - using JSON-like notation (e.g. { foo: 'bar' })
booleans - true and false
null - null
exponential - also known as scientific (e.g. 1.99E+3 or 1e-2)
Last updated
Was this helpful?

