External rules
This recipe explains the concept of an external rule, how to configure it with Snag and how to issue rewards to your users.
What is an external loyalty rule?
You may wish to track user behaviour in contexts that Snag is unable to obtain a data source for (e.g. in a non-web/blockchain based game). For this and similar cases, Snag provides the concept of external rules.
An external rule is mostly the same as a standard loyalty rule and differs only in that it contains no built-in execution and evaluation logic.
Instead, this is done application-side (e.g. in-game) and, when a rewardable action is identified, Snag’s POST /api/loyalty/rules/{id}/complete
endpoint can be hit.
This tells Snag that a given rule was completed by the given user(s) and issues the associated reward.
You can get more details on how to complete a rule in the Submit and verify loyalty rule completion recipe.
The id returned in the response will be used to complete the rule when a user performs the required action.
Evaluating external rules
Unlike built-in rules, the evaluation of external rules happens within your own system. This means you must track the user behavior (e.g., game milestones or external API interactions) and determine when a rule is completed.
Once a rewardable action is identified, you can programmatically notify Snag by completing the external rule using the API (see next step).
How to issue points for users who complete an external rule
To issue points for a user who completes an external rule, use the POST /api/loyalty/rules/{id}/complete
endpoint. This endpoint informs Snag that the rule has been satisfied for a specific user and triggers the reward.
You can get more details on how to complete a rule in the Submit and verify loyalty rule completion recipe.
Once the request is processed, Snag will issue the reward to the user based on the rule’s configuration.
Summary Workflow
-
Create the External Rule: Use our admin dashboard to create the rule.
-
Track Behavior: Use your application to monitor user actions that meet the rule’s criteria.
-
Complete the Rule: When a user completes the action, submit the rule completion to Snag using the API, more details can be found in the Submit and verify loyalty rule completion recipe.
Feedback
We value your feedback! Please share your thoughts below:
Was this page helpful?