Events

Allows event tracking

Methods

Name Description
agent.join Fires when agent joins a chat or when page is loaded and agent is already in chat. Can be used to modify agent properties like name or description based on your conditions (e.g: language, name).
agent.leave Fires when agent leave chat.
event Fires when occours chat event. Data are same as data sended to google analytics.
login Fires when visitor finish login.
message Fires when visitor, agent or trigger send message into chat. Fired for all messages in chat.
render Fires before chat is rendered.
rendered Fires after chat was rendered.
sent Fires when user sent message.
status Fires when online status of Smartsupp account is changed and when chat (page) is loaded.
startup Fires when chat is loaded.

agent.join

Fires when agent joins a chat or when page is loaded and agent is already in chat. Can be used to modify agent properties like name or description based on your conditions (e.g: language, name).

<script> // change agent name and note for all agents smartsupp('on', 'agent.join', function(model, agent) { agent.nickname = 'Custom Name'; agent.note = 'Custom description'; }); // change agent name and note for specified agent smartsupp('on', 'agent.join', function(model, agent) { if (agent.nickname.indexOf('John Doe') >= 0 /* || agent.id = 123 */) { agent.nickname = 'Custom Name'; agent.note = 'Custom description'; } }); // change agent name and note for by language smartsupp('on', 'agent.join', function(model, agent) { if (model.get('lang') == 'fr') { // model.get('lang') returns current chat language agent.nickname = 'Nom personnalisée'; agent.note = 'Description personnalisée'; } else { agent.nickname = 'Custom Name'; agent.note = 'Custom description'; } }); </script>

agent.leave

Fires when agent leave chat.

<script> smartsupp('on', 'agent.leave', function(model, agent) { console.log("Agent leave from chat:", agent); }); </script>

event

Fires when occours chat event. Data are same as data sended to google analytics.

<script> var keenClient = new Keen({ ... }); smartsupp('on', 'event', function(category, action, label) { // send event data to other service e.g.: keen.io (https://keen.io) keenClient.addEvent('smartsupp_event', { category: category, action: action, label: label }); }); </script>

login

Fires when visitor finish login.

<script> smartsupp('on', 'login', function(values) { console.log('login values: ', values); }); </script>

message

Fires when visitor, agent or trigger send message into chat. Fired for all messages in chat.

<script> smartsupp('on', 'message', function(model, message) { if (message.type == 'visitor') { console.log('visitor message:', message.content); } else if (message.type == 'agent') { if (message.triggeredBy) { console.log('triggered message:', message.content, '; trigger:'+message.triggeredBy); } else { console.log('agent message:', message.content); } } }); </script>

render

Fires before chat is rendered.

<script> smartsupp('on', 'render', function() { console.log('render'); }); </script>

rendered

Fires after chat was rendered.

<script> smartsupp('on', 'rendered', function() { console.log('rendered'); }); </script>

sent

Fires when user sent message.

<script> smartsupp('on', 'sent', function(message) { console.log('sent message:', message); }); </script>

status

Fires when online status of Smartsupp account is changed and when chat (page) is loaded.

<script> // Change banner by status smartsupp('on', 'status', function(status) { if(status == 'online') { smartsupp('banner:set', 'image', { src: 'PATH/banners/banner_online.png' }); } else { smartsupp('banner:set', 'image', { src: 'PATH/banners/banner_offline.png' }); } }); </script>

startup

Fires when chat is loaded.

<script> smartsupp('on', 'startup', function() { console.log('startup'); }); </script>