Collect 1 point per dollar spent
Prerequisites
- Create your Integration API key.
- If you haven't done so already, fork our Sample Campaigns collection in Postman:
- In the Campaign Manager, open the MEDIUM-LOYALTY: Collect 1 point per $ spent demo campaign and click Activate Campaign.
- Open the Rule Builder to get some context.
Let's create a promotion rule that awards customers with one loyalty point per dollar they spend on accessories.
Creating the loyalty wallet promotion
In the current scenario, let's use one rule and name it 1 point per $ spent
.
Cart item filters
Let's start by creating the cart item filter to find and count the accessories in the session:
- Click Add Filter.
- Click Add Filter Step and select Filter items by condition.
- Set the filter to Item category (Item) is equal to
Accessories
. - In Save As, type
Accessories
and click Save Filter. This creates the Accessories filter. The Accessories item count (Accessories) filter is automatically created, which returns the number of items in the filter.
Condition
Talon.One offers many conditions. Let's add the condition to check if there are accessories in the session:
- Click Add condition and select Check attribute value.
- Compose the following expression: Accessories item count (Accessories)
is greater than 0
.
Effect
Let's set the Add loyalty points per item effect:
- Set Cart item filter:
Accessories
. - Set Loyalty program to Sample Wallet. This wallet is created by default in your demo deployment.
- Set Recipient to Current Customer.
- Set Reason to
1 point per $ spent on accessories
to identify why they were awarded a point. - Set Amount of point to: Quantity of item (Item)
*
Price of item (Item). - Select the whole expression and click Round up to get:
Round_up(
Quantity of item (Item)*
Price of item (Item))
.
Running the campaign
To run the campaign, use the following payload sent to the Integration API's Update customer session endpoint:
- 🚀 Request
- ✅ Response
Let's create a session with two items:
- Line 12: ProductC is an accessory.
- Line 22: ProductA isn't an accessory and will be excluded from point calculation.
CURL -X PUT https://mycompany.europe-west1.talon.one/v2/customer_sessions/my_session_id -d
'{
"customerSession": {
"profileId": "EWRU87GENV",
"state": "closed",
"cartItems": [
{
"name": "ProductC",
"sku": "sku-00004",
"quantity": 1,
"price": 200,
"Category": "Accessories",
"weight": 0,
"position": 0,
"attributes": {}
},
{
"name": "ProductA",
"sku": "sku-00001",
"quantity": 1,
"price": 100,
"Category": "",
"weight": 0,
"position": 0,
"attributes": {}
}
],
"couponCodes": [
""
],
"referralCode": "",
"attributes": {},
"additionalCosts": {}
},
"responseContent": []
}'
We receive this response, which shows our effect in the effects
array.
Line 15 and 16: The customer with the id shown in recipientIntegrationId
got
the amount of points specified in value
. Note that the value
property matches only
the price of ProductC, the only accessory of the session.
{
"createdCoupons": [],
"createdReferrals": [],
"effects": [
{
"campaignId": 248,
"rulesetId": 475,
"ruleIndex": 0,
"ruleName": "1 point per $ spent",
"effectType": "addLoyaltyPoints",
"props": {
"name": "1 point per $1 spent on accessories",
"programId": 1,
"subLedgerId": "",
"value": 200,
"recipientIntegrationId": "GHYAHGY74",
"transactionUUID": "e2aaf43b-6ce9-4ea4-ab2e-e33dd9c2ae73",
"cartItemPosition": 0,
"cartItemSubPosition": 0
}
}
]
}
- You can reward customers with loyalty points with the Add loyalty points effect.
- Loyalty points are kept in a given loyalty program.