Skip to main content

eCommerce

This guide is for companies operating ecommerce businesses. It shows how Talon.One can be used to provide loyalty programs and discounts. There are two steps to using Talon.One:

  1. Notify the API of assorted customer activities.
  2. Handle the effects returned by the API.

The decision of which effects to return for a given customer activity is controlled by the Talon.One Rule Engine.

1. Send activity notifications

The easiest way to get started is with our SDKs. After the SDK has been installed & configured you will use the following API calls:

Below we show example API calls for different customer activities: viewing products, placing an order, and entering a promotional code.

1.1. User views products on a category page

Track a custom viewedCategory event with a category and product attribute whenever a user visits a category page:

talon.trackEventV2("session1234", "viewedCategory", { category: `Wintershoes`, product: `SKU378312` })

This allows campaigns to offer promotions specific to the category and/or the products the user is currently viewing. For example, a response may contain the following effect:

["offerDiscount", "Now 10% on Wintershoes"]

1.2. User places an order

Send a session update with the current cart items whenever a user updates their order:

talon.updateCustomerSession("session1234", {
attributes: {
ShopId: 53
},
cartItems: [{
sku: "SKU378312",
name: "Timberland Shoes",
quantity: 1,
price: 110.99,
attributes: {
category: `Wintershoes`
}
}]
})

This allows campaigns in the Rule Engine to trigger effects based on the cart contents. For example, we can create a campaign that gives a 10$ discount when the category is Wintershoes:

["setNewQuote", "Wintershoe Special", 10.00]

1.3. User enters a promo code

Send a session update whenever a user enters a promo code:

talon.updateCustomerSession("session-1234", { coupon: 'Awwww it`s cold!' })

The Talon.One Rule Engine will validate the code, and return either an acceptCoupon effect (and any other effects that were triggered), or a rejectCoupon effect indicating that the coupon was not valid.

Successful validation:

["acceptCoupon", "Awwww it`s cold!"]
["setDiscount", "$20 on Winterclothes", 20]

Unsuccessful validation:

["rejectCoupon", "Awwww it`s cold!"]

2. Handling effects

The Rule Engine sends back discounts and other actions to perform in the form of effects. These are handled in your integration by registering effect handlers:

talon.handleEffect('setDiscount', function (context, label, amount) {
context.order.addOrReplaceDiscount(label, amount)
})

3. References

  • See Handling effects for more information on the types of effects the Rule Engine might return and their arguments.
  • See Data Model overview for more information on what information you can use in your campaigns to conditionally trigger effects.