E-Commerce

This guide is for companies operating e-commerce 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 our API of assorted customer activities.

  2. Handle the effects returned by our 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.trackEvent("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,
    cost: 110.99,
    attributes: {
      category: `Wintershoes`
    }
  }]
})

This allows campaigns in the rule engine to trigger effects based on the cart contents. E.g. we could 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. Handle effects

The rule engine will send back discounts and other actions to take 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.