olark('api.chat.onMessageToVisitor', function(event) {
	// Your callback function
});

Arguments

  • event.message.body
    the contents of the message
  • event.message.nickname
    the display name of the operator

Notes

Whenever a message is sent to the visitor, this will call the given callback with an event object.

Track operator response times

Use your favorite analytics system to keep track of how long it takes an operator to respond to a visitor:

<script>
olark('api.chat.onMessageToOperator', function(event) {

    // Get the timestamp for when the visitor sends a message
    var visitorSentAt = +new Date;

    olark('api.chat.onMessageToVisitor', function(event) {


        // Get the timestamp for when the operator sends a message
        var operatorSentAt = +new Date;

        // Calculate the difference between the two times and track the event
        // Check your anayltics software API to see how to push an event
        yourAnalytics.track("operator_response_time", operatorSentAt - visitorSentAt);

    });

});
</script>

If these statistics sounds cool to you, you should probably try enabling our Google Analytics for a more in-depth integration with Google Analytics.