Welcome To Our Customer Service Portal


Nanorep Events API (Arcade and Modern)

Events API

Events API allows the customer to hook into various Nanorep widget events.

For example, you can use this API to push different Nanorep events to a 3rd party BI system (e.g. Universal Analytics) and generate Nanorep related Reports.

Note: this API is valid for Arcade and Modern styles only. Please see this guide if you are using Slim version of widget.

Supported Events:

  • load: Fires when the widget is fully loaded
  • userStartedTyping: Fires when User starts typing into the search box
  • query: Fires after the user finishes typing and the query is sent to the server
  • incomingSearchResults: Fires when the search results arrive at the widget
    • hasResults(bool) - indicates if results were given to the query.
    • isAutoQuestion(bool) - indicates if the query was an auto question.
    • query(string) - the query asked.
    • results(Json Array) - the results to the query. Each item in the array is a json object:  { answerId(string), title(string), body(string) }
  • escalation: Fires when the user performed an escalation (e.g email, chat)
  • like: Fires when the user clicked 'Like' on a search result
// For floating widgets
_nRepData["float"] =
{
     //.... //
     events:
     {
          eventName: function(parameters) {}
     }
     //.... //
}
// For the embedded widgets
_nRepData["embed"] =
{
     //.... //
     events:
     {
          eventName: function(parameters) {}
     }
     //.... //
}
// For both widgets
_nRepData["events"] =
{
     eventName: function(parameters) {}
};

 

Usage Examples:

// Widget loaded:
load: function(){alert("widget loaded!");}
// User started typing:
userStartedTyping: function(){alert("user started typing");}
// User asked a question:
query: function(query, isAutoQuestion){alert("user asked: " + query + ". is
auto ? : " + isAutoQuestion);}
// Incoming search results:
incomingSearchResults: function(hasResults){alert("incoming search results.
has results: " + hasResults);}
// User performed escalation:
escalation: function(type, query){alert("Escalation occurred. type: " + type
+ ". user query: " + query);}
// User clicked 'Like':
like : function(query, answer){alert("User liked the answer: " + answer + "
for the query: " + query);}

 

Floating widget script example:

<!--do not modify this script -->
<div class='Nanorep_loadingData' id='NanorepProxyContainer' style='position:absolute;top:-500px;left:0px;'></div>
<script type='text/javascript'>var _nRepData = _nRepData || []; _nRepData['kb'] = '24218399'; _nRepData['float'] = {account: 'nisim', cdcVersion: 3, cdcFrame: '', scriptVersion: '2.19.2.2',  events:
     {
          userStartedTyping: function(){alert("user started typing");}}
     }
/* API here */;
(function(){var windowLoadFunc = function(){var _nRepData = window._nRepData || [];_nRepData['windowLoaded'] = true;if (typeof(_nRepData['windowOnload']) === 'function') _nRepData['windowOnload']();};if (window.attachEvent)window.attachEvent('onload', windowLoadFunc);else if (window.addEventListener)window.addEventListener('load', windowLoadFunc, false);var sc = document.createElement('script');sc.type = 'text/javascript';sc.async = true;sc.defer = true;sc.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'my.Nanorep.com/widget/scripts/float.js';var _head = document.getElementsByTagName('head')[0];_head.appendChild(sc);})();
</script>