Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

// This event triggers when the number of unread messages changes
JobPal.on('unreadCount', function(unreadCount) {
    console.log('the number of unread messages was updated', unreadCount);
});


chatbot widget opened

// This event triggers when the chatbot widget is opened
JobPal.on('widget:opened', function() {
    console.log('Widget is opened!');
});

...

// This event triggers when the chatbot widget is closed
JobPal.on('widget:closed', function() {
    console.log('Widget is closed!');
});

Tracking user user/chatbot interaction in Google Analytics

A typical use case of event handling is to track user actions in external tracking systems, for example Google Analytics.

The code snippet below will record a “MessageSent” event action in Google Analytics whenever an enduser sends a message to the chatbot.

// Google Analytics tracking of messages sent by endusers
JobPal.on('message:sent', function(message){
ga('send', 'event', 'Chatbot', 'MessageSent');
});

Where “Chatbot” is the event category, “MessageSent” is the event action. Additionally you might add parameters for event label and event value. You can learn more about event measurement in Google Analytics here.

Please don’t forget to add this lines before invoking the JobPal.init function!

The setup above would allow you to compare behavioural differences (like conversion rates) in Google Analytics between endusers interacting with the chatbot and endusers not using the chatbot.