Alcmeon chat events

Javascript Event

AlcmeonChat emits standard Javascript events (document.dispatchEvent). Each client can listen to them using document.addEventListener. You must be in the same HTML document as AlcmeonChat to listen to the event (i.e., where the JS snippet to load AlcmeonChat is inserted—see the Javascript SDK documentation). The event cannot bubble up from nested iframes.

The Javascript event to listen for is always alcmeonChatEvent. The purpose of having a single event is to simplify the configuration of analytics tools.

This event contains a detail object. The event label is found in detail.eventLabel. Additional optional parameters are found in detail.data.

Event Names

The possible event labels are as follows:

Standard chat actions

openChat
closeChat
sendMessage

detail.data is always empty in these cases.

Automations

(optional, must check “Trigger a Javascript event”)

automation-openChat
automation-closeChat
automation-showButton
automation-hideButton
automation-displayInvitation

detail.data may or may not be empty.

In automations (action “Trigger a custom JavaScript event”) and in the bot editor (box “Alcmeon Action”, type “Trigger an event in the widget”), you can also define events with custom names. In this case, eventLabel will contain that custom name.

Examples

Javascript

document.addEventListener('alcmeonChatEvent', function (event) {
  console.log('alcmeonChatEvent', event.detail.eventLabel, event.detail.data);
});

Google Tag Manager

<script type="text/javascript">
  document.addEventListener('alcmeonChatEvent', function (e) {
    window.dataLayer = dataLayer || [];
    dataLayer.push({
      event: 'alcmeonChatEvent',
      eventLabel: e.detail.eventLabel,
      data : e.detail.data
    });
  });
</script>