Attribute automations allow you to update the value of any number type attribute in one of two ways:
Event-based: Updates the attribute value when a specific event occurs.
Schedule-based: Updates the attribute value on a recurring cron schedule.
In both cases, you specify the trigger type, along with the event or schedule that triggers the automation, and the math.js expression that specifies the attribute change.
To create an attribute automation, select any numeric attribute under Users> Attributes and then select Add Automation. These attribute value changes are reflected for all users and can be viewed in the All Users tab in the Loyalty Hub or under Data> User Profiles.
Some example use cases include:
Reset your user's weekly_bets attribute to
0every week:Using an event-based automation:
Select a scheduled event.
Set the Expression, the
math.jsformula used to calculate the new attribute value, to0. This resets the attribute back to zero every time the event fires.
Using a scheduled automation (recommended):
Set the Cron Expression to
0 0 * * 1.Set the Expression, the
math.jsformula used to calculate the new attribute value, to0. This resets the attribute back to zero every Monday at midnight.
Increment a user's total_bets attribute by 1 each time they place a bet:
Using an event-based automation:
Select the bet placed event.
Set the Expression to
aggregatedValue + 1. This adds 1 to the attribute value every time the event fires.
Accumulate the total amount a user has deposited in a total_deposits attribute:
Using an event-based automation:
Select the deposit event.
Set the Expression to
aggregatedValue + event.body.amount. This adds the amount from the event to the attribute value every time the event fires.
Configure Attribute Automation
To configure an automation for an attribute, do the following:
Select the attribute under Loyalty Hub > Users > Attributes
Click Add Automation
Under Trigger Type, choose how the automation runs:
Event-based: Triggers when a specific event occurs.
Schedule-based: Triggers on a cron schedule.
Depending on the trigger type selected:
Event-based: Under Choose Target, specify the event that triggers the automation. You can also select Add Requirement to add conditions on the event's properties, so the automation only runs for events that meet those conditions.
Schedule-based: Under Schedule, enter a Cron Expression, and optionally select Add Requirement to filter by user attributes, limiting the automation to users matching specific conditions.
Cron expression format
Only exact-hour cron expressions are supported. The minute field must be a fixed value of
0and cannot use wildcards, ranges, steps, or lists.For example,
0 * * * *runs every hour on the hour, and0 4 * * *runs daily at 4am. Expressions such as*/5 * * * *,0-5 * * * *, or0,30 * * * *are rejected.Scheduled automations run on creation
A schedule-based automation runs once immediately after you create it, and then runs according to its cron schedule.
Under Create Modifier Expression, add your
math.jsexpression(Optional) under Advanced Configurations choose the internal title and description of this automation.
Tip
If you're adding an automation rule for the attributes imported from the Xtremepush CDP, the attribute value changes also reflect under Data > User Profiles for each user.