Listen to events emitted by Elevio. Note that this is the only method that can be called before the load event is emitted.

Example

window._elev.on('load', function(_elev) {
  console.log('Elevio loaded', _elev);
});

Signature

window._elev.on(type, callback);

type (required)

The type of event to listen to. Can be one of:

  • load
    Called after the Elevio script has loaded, but before the Elevio app has been initialised. You should modify initial settings here. As a convenience, the callback has window._elev as it’s first argument.
  • ready
    Called after the Elevio app has been initialised.
  • widget:opened
    Called after the widget is opened.
  • widget:closed
    Called after the widget is closed.
  • module:opened
    Called after a module is opened. The callback has the module ID as it’s first argument.
  • popup:opened
    Called after a popup is opened. The callback has the article ID as it’s first argument.
  • popup:closed
    Called after a popup is closed. The callback has the article ID as it’s first argument.
  • search:query
    Called when results for a search query are shown to user. The callback has an object as it’s first argument, with query and results properties.
  • search:article:clicked
    Called when results for a search query is clicked by a user. The callback returns an object with the articleId, categoryId and the source. The source is what is defined in the elevio search element or defaults to 'custom-element' if not defined. If the link is click inside the assistant then the source is 'assistant'.
  • category:article:clicked
    Called when an article is clicked in the category display. The callback returns an object with the articleId, categoryId and the source. The source is what is defined in the elevio category custom element or defaults to 'custom-element' if not defined. If the link is click inside the assistant then the source is 'assistant'.
  • widget:article:view
    Called after an article is viewed in the widget. The callback has the article ID as it’s first argument.
  • suggestions:article:clicked
    Called after a suggestion link is clicked.The callback returns an object with the articleId and the source. The source is what is defined in the elevio suggestion custom element or defaults to 'custom-element' if not defined. If the link is click inside the assistant then the source is 'assistant'.
  • related:article:clicked
    Called after a related article link is clicked. The callback returns an object with the articleId of the link clicked, the source, and the relatedFrom which is the article ID of the article from which related articles were displayed. The source is what is defined in the elevio suggestion custom element or defaults to 'custom-element' if not defined.
  • article:interlink:clicked
    Called after an article interlink is clicked. The callback returns an object of the ID of the module or article interlink that was clicked, the type of interlink clicked (elevioModule, elevioArticle, etc) and clickedFrom which is the article ID of the article from which the interlink was clicked.
  • article:feedback:reaction
    Called after the feedback reaction icon is clicked, either positive or negative. The callback returns an object with id for article id, reaction 1 for positive 0 for negative and title with the title of the article.
  • article:feedback:text
    Called after feedback text is left for an article. The callback return on object with id for the article id, text for the text the user has submitted and title for the article title.
  • article:kblink:clicked
    Called when a user clicks on the icon to open the article in the knowledge base. The callback returns the id of the article that was clicked.

Additionally, you can listen to the loading states of the following components: article, category, article-feedback, article-related and suggestions.

This may be useful in the event that you are using elevio-elements and want to provide your own UI for loading or error states (see more here). We have also exposed error events for where default error views exist for individual components.

Can be one of:

  • article:data:loaded
    Called after an article has loaded. The callback returns the articleId of the article, and the source name of the article component that was clicked.
  • article:data:error
    Called when loading an article returns an error. The callback returns the articleId of the article that was clicked, and the source name of the article component that was clicked
  • category:data:loaded
    Called after a category has loaded. The callback returns the id, the articles, source, subCategories and title of the component where set. 
  • article:feedback:loading
    Called when the article feedback component enters a loading state (e.g. when the article feedback stage* is changing). The callback returns the source, the stage* and the articleId of the feedback component.
  • article:feedback:loaded
    Called when the article feedback component completes submission of feedback. The callback returns the articleId, the stage*, the body, title and the source of the feedback component.
  • article:feedback:error
    Called when the article feedback component returns an error. The callback returns the articleId, the stage* and the source of the feedback component.
  • article:related:loaded
    Called when the article related component has loaded. The callback returns the source name of the article related component.
  • suggestions:data:loaded
    Called after the suggestions component has loaded. The callback returns the source name of the article related component.
  • suggestions:data:error
    Called when the suggestions component returns an error. The callback returns the source name of the article related component.

The Feedback stage

When the end user initially submits a feedback reaction (i.e. clicks the thumbs down icon or the thumbs up icon), the stage will be reaction.

If a positive reaction (thumbs up) was submitted, the stage will be success.

If the end user has submitted a negative reaction, the end user will see a text field to provide feedback in; this stage is text.

callback (required)

The function to be called. Arguments are as per the type above.