Skip to main content

30% off with a coupon code

Prerequisites
Before you start, ensure you:
  1. Create your Integration API key.
  2. If you haven't done so already, fork our Sample Campaigns collection in Postman: Run in Postman.
  3. In the Campaign Manager, open the EASY-COUPON: 30% off with coupon code demo campaign and click Activate Campaign.
  4. Open the Rule Builder to get some context.

Let's create a promotion rule that provides a 30% discount to customers who enter the SUMMER2023 coupon code. The code has unlimited redemptions and no further limitations.

This tutorial uses concepts covered in the Creating a discount based on session value tutorial, where we learned how to set up a rule triggering on certain events.

Creating the coupon promotion

In the current scenario, let's use one rule and name it 30% off with coupon code.

Condition

Talon.One offers many conditions. In our case we need the following condition:

  1. Click Add condition and select Coupon code is valid.

This condition allows you to check whether the coupon code(s) provided in the session by the customer are valid. This condition also automatically redeems the coupon code when the customer session is closing. Learn more about Customer session states.

Effect

Let's set the Discount session total effect:

  1. Set the Name to something descriptive, such as 30% off.
  2. Set the Discount value to [Session.Total]*30%.

As in the previous tutorials, we calculate the discount value using the same Session Total (Current session) attribute.

Running the campaign

note

The SUMMER2023 coupon code is already created in the demo campaign.

To run the campaign, use the following payload sent to the Integration API's Update customer session endpoint:

To trigger the rule, we must:

  1. Line 19: Add the valid coupon code.
Sending a session update
CURL -X PUT https://mycompany.europe-west1.talon.one/v2/customer_sessions/my_session_id -d
'{
"customerSession": {
"profileId": "{{Integration_id}}",
"state": "open",
"cartItems": [
{
"name": "ProductA",
"sku": "sku-00001",
"quantity": 1,
"price": 233,
"Category": "",
"weight": 0,
"position": 0,
"attributes": {}
}
],
"couponCodes": [
"SUMMER2023"
],
"referralCode": "",
"attributes": {},
"additionalCosts": {}
},
"responseContent": []
}'
Key Takeaways
  • Checking if a coupon is valid is done with the Coupon code is valid condition.
  • Coupons are created inside campaigns.
  • The Coupon code is valid condition also automatically redeems all valid coupons in the session when the session closes.
  • Setting the state of a session and adding a coupon code is done via the Update customer session endpoint.