Event callbacks

Breaking changes prior to Oct 11, 2022

This doc contains a proposal that includes some breaking changes:

  • timestamp field is moved from top-level of onEvent to inside context
  • customerEvaluation is removed from onSuccess
  • onClose won't include the order object
  • all page view events will use a single event-type called page-viewed
  • error field will be renamed as errorMessage in onFailure
  • onEvent fields will be nested inside of context

There are 4 different callback event functions you can receive from our Slope.js front-end widget. All of the functions will return a single argument that contains an object


Frontend callbacks data can't be trusted

Since all frontend code is executed by the by the end user, the data can be tampered. You should only use the callback data for display purposes only. To obtain trusted data, fetch directly from our backend API from your backend server.


Called when the end-user has completed the flow and has closed the modal.

  customer: { ... }, // Customer object, see /customers/:id API. May be null for checkout flow.
  order: { ... }, // Order object, see /orders/:id API. May be null for non-checkout flow
  context: { ... } // see below


Called when the end-user has closed the modal before reaching the final page. Can be considered a drop-off from the user. The context object will contain the current page which can be used to track the drop-off page.

  context: { ... } // see below


Called when an error has occurred that has prevented the user from moving forward. This will be triggered after the user can closed the error screen.

  errorMessage: 'Error message string',
  errorCode: 'some-error-type',
  context: { ... } // see below


Called for analytics only to send tracking events. The page-viewed event is called the most frequently and is called for each page change.

Example payload:

    type: "page-viewed",
    attributes: { ... }, // optional additional metadata about the event
    context: { ... } // see below

Event types


context object


Context schema may change

The context schema may change anytime and you should only used for debugging and analytics only. If storing the context, it should be serialized as a JSON string

The context field will be automatically added to all event callbacks. However, in some instances where an expected error occurs at the root level this context object may be null. See example context object below:

  url_path: "/pre_qualify", // Naming may change frequently.
  session_id: "678bf2b8-452a-43a9-b29c-31e7a46bfdc0",
  view_id: "125bd189-014d-431a-b2e4-822c1a1824ea",
  view_name: "pre_qualify",
  merchant_id: "mch_24GT1PAHxi7yNWJh2C4mznL9Paz",
  cutomer_id: "cust_26POi4qjL6JmTQTh72U3ddmWPn5",
  flow: "pre_qualify",
  timestamp: 1664406660987