Earn rules specify how members earn metrics (such as points) for each activity type. Cheetah Digital Loyalty has a purpose-built rule engine to handle common loyalty rules scenario such as layering promotional rules on top of base rules and applying only one promotion from applicable promotions.
Each row on the Rules | Earn Rules screen represents one rule. A rule has the following elements:
Calculations and conditions are expressions written in Groovy language. Helper Calculation Functions encapsulate common scenarios and simplify rule authoring. Further, custom encapsulation of calculation or condition scenarios can be written as member functions. Many rule calculations may be simply accomplished as a lookup from a spreadsheet of key/value pairs.
In Settings | Earn Rule Settings, Rule Groups and Combinations can be set up which determine how the rule engine behaves.
Rule Groups in addition to providing organization, are important semantic tools to implement common loyalty scenarios. Each rule group supports one of the following strategy for handling multiple applicable rules within a group:
Rule combinations allow results from multiple rule groups to be summed or combined using other functions. A common scenario is to create a combination - promotions + base - to say that promotional rules are applied on top of base rules.
For each rule group, a rule group result for the metric is calculated either by summing or using the best applicable rule results for the group, as per the group’s strategy. Then these group results are combined using specified combinations.
The best result from among all the results from rule groups and combination is the final calculated value for the metric.
The above diagram shows a simple scenario where there are 2 rule groups, first of type ‘sum all applicable rules’, and second of type ‘use best result’. Let’s assume all the rules are applicable.
Then the result for the first group is 30, that is 10 + 20, and the result from the second group is 15, that is best of 5 and 15.
The final result then is 30, that is best of 30 and 15.
Now, let’s add a combination to this scenario, as shown in the following diagram.
The result for the combination is result of group 1 + group 2, that is 30 + 15 = 45.
The final result now is 45, the best of 30, 15, and 45.
For every PoS Purchase, give 1 point for 1$ spent
getActivityValue('amount')
Give 15 points bonus for purchases more than $200
getActivityValue('amount') >= 200
Advanced. Give different points for items purchased. Lookup - point_lookup - defines how many points to give for every $ spend for items in different category. The result in the lookup is stored in column point_factor. The point_factor from the lookup needs to be multiplied by the amount spent on the item.
sumActivityItems({item -> getLookupValue ('point_lookup', item.category, 'point_factor') * item.amount})