api.chat.onMessageToOperator
Whenever a message is sent to the operator, this will call the given callback with an event object
event.message.bodythe contents of the message
Examples
Use your favorite analytics system to keep track of visitors who have sent a message to an operator (since they might be more valuable):
olark('api.chat.onMessageToOperator', function(event) {
yourAnalytics.track("chatted_with_operator");
});
Maybe you want to keep track of positive vs. negative reactions. You could watch when people send you smileys, indicating that they are happy:
olark('api.chat.onMessageToOperator', function(event) {
if (event.body.message.indexOf(":)") != -1) {
yourAnalytics.track("customer_is_happy");
}
});
If these statistics sounds cool to you, you should probably try enabling our
Google Analytics plugin
for a more in-depth integration with Google Analytics.
Discussion
Feel free to propose good uses for this method, or even drop us some suggestions for improvement! You can also join our mailing list to collaborate with other developers and get updates from us.