Campaigns

Formulas

Calculate how many units a campaign gives from the contents of the cart.

Unit effects such as Add units take either a fixed number, for example 100, or a formula that calculates the amount from the transaction. Open the formula editor with the Σ button next to the effect's value.

items.total * 0.02

This formula gives 2 units for every 100 of the transaction's value, so a purchase of 5,000 earns 100 points.

Formula editor

Variables

VariableValue
items.countNumber of items in the transaction.
items.totalTotal value of the items in the transaction.
sku('SKU').countNumber of items with this SKU.
sku('SKU').totalTotal value of the items with this SKU.
category('CATEGORY').countNumber of items in this category.
category('CATEGORY').totalTotal value of the items in this category.

SKU and CATEGORY are matched against the sku and category your integration sends on each product of the transaction, so write them exactly as you send them.

Operators

Use +, -, * and /, with parentheses to group.

Functions

FunctionExampleResult
floorfloor(5.9)5, rounded down
roundround(5.5)6, rounded to the nearest whole number
ceilceil(5.1)6, rounded up
absabs(-1.23)1.23, the absolute value
min, maxmin([items.total * 0.02, 500])The smallest or largest value in the list
sum, avgsum([1, 2, 3])6, the sum or average of the list
randrand(100)A random whole number from 1 to 100

Examples

GoalFormula
2 points per 100 spentitems.total * 0.02
1 point per full 100 spentfloor(items.total / 100)
10 points per itemitems.count * 10
5 points per 100 spent on one categorycategory('Electronics').total * 0.05
50 points per unit of one productsku('SH-100').count * 50
2% back, at most 500 pointsmin([items.total * 0.02, 500])

When the campaign should count only some purchases, pair the formula with a condition. For example, use category('Electronics').total * 0.05 with the condition Has product from category Electronics.