API Event Hooks

Event hooks allow you to run your own code during different stages of the Verint XM Web SDK Trigger Code lifecycle, as well as request a Boolean about whether a particular Web SDK Trigger Code lifecycle event has been executed.


Sample API Hook Use Cases

  • You want to alert a Thank You message once the customer accepts the Verint XM survey invitation.
  • You want to know whether an invitation has already been presented.

Available Event Hooks:

  • onLoaded - Fires after trigger code has been loaded.
  • onInitialized - Fires after trigger code base been initialized.
  • onInviteShown - Fires after the invitation has been presented.
  • onInviteAccepted - Fires if the invitation has been accepted.
  • onInviteAbandoned - Fires if the invitation has been abandoned.
  • onInviteDeclined - Fires if the invitation has been declined.
  • onTrackerShown - Fires after the tracker window is shown.
  • onFeedbackShown - Fires after the Feedback Survey is opened (Requires Web SDK 19.7.1+).
  • onFeedbackSubmitted - Fires when a Feedback Survey is submitted and contains the data object, including scores and comments.
  • onFeedbackClosed - Fires after the Feedback Survey is closed (Requires Web SDK 19.7.1+).

Event Hook API:

  • .didFire - Checks if the event has happened. Returns a Boolean true or false.
  • .subscribe(cb, once, stragglers) - Executes your callback function once the event has happened. Returns a subscription object.
  • cb - Optional parameter. A function that is executed once the event fires. This is also executed immediately if the event has fired and the stragglers flag is set to true.
  • once - Optional parameter. Defaults to false. If set to true, a one-time subscription is created that is removed once the event has fired.
  • stragglers - Optional parameter. Defaults to false. If set to true, fires the event again for this callback if it has already fired once before.

Sample Usage:

The code below can be used to present an alert after the invitation has been accepted. Since the once flag is set to true, the subscription is deleted after the event has fired once. Since the stragglers flag has been set to true, the callback is executed even if the invitation has already been accepted by the time the subscription is created.

// This should appear below the ForeSee Embed Snippet

fsReady(function(){
  FSR.onInviteAccepted.subscribe(
    function() {
      alert('Thank you for accepting our invite!');
    }, true, true
  );    
});