Events

Allows event tracking

Methods

Název Popis
agent.join Fires when agent is joined into chat, or when page is loaded and agent is already in chat. Can by used to change agent properties like name or description by 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 Spustí se po té, co se návštevník zaloguje.
message Spustí se, když návštěvník, operátor nebo trigger odešle zprávu do chatu. Spustí se pro všechny zprávy v chatu.
render Fires before chat is rendered.
rendered Fires after chat was rendered.
sent Spustí se v momentě, kdy uživatel odešle zprávu.
status Fires when visitor`s status is changed.
startup Fires when chat is loaded.

agent.join

Fires when agent is joined into chat, or when page is loaded and agent is already in chat. Can by used to change agent properties like name or description by 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

Spustí se po té, co se návštevník zaloguje.

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

message

Spustí se, když návštěvník, operátor nebo trigger odešle zprávu do chatu. Spustí se pro všechny zprávy v chatu.

<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

Spustí se v momentě, kdy uživatel odešle zprávu.

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

status

Fires when visitor`s status is changed.

<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>