The events are automatically pushed to the data layer array.

Pass Events in JavaScript

Pass the events in the widgetOptions object to receive the events in JavaScript.
The widgetOptions object is the part of the installation script where you pass your apiKey and snippetId.


<!-- Start of Glassix Chat Widget -->
    var widgetOptions = {
         apiKey: "your-api-key",
         snippetId: "your-snipppet-id",
         events: {
        'initialized': ()=> console.log("Widget initialized."),
        'attached': ()=> console.log("Widget attached"),
        'destroyed': ()=> console.log("Widget destroyed."),
        'visiblity': (isVisible)=> console.log(isVisible ? "Widget is visible" : "Widget is hidden"),
        'newTicket': (nextTicketId)=> console.log("new ticket created"),
        'newMessage': ()=> console.log("New message."),
        'protocolBadgeClicked': (protocolType, departmentIdentifier) => console.log("Channel clicked. protocolType: " + protocolType + " departmentIdentifier: " + departmentIdentifier)
    (function(n){var u=function(){GlassixWidgetClient&&typeof GlassixWidgetClient=="function"?(window.widgetClient=new GlassixWidgetClient(n),widgetClient.attach(),window.glassixWidgetScriptLoaded&&window.glassixWidgetScriptLoaded()):f()},f=function(){r.src="";r.onload=u;document.body.removeChild(t);i.parentNode.insertBefore(r,i)},i=document.getElementsByTagName("script")[0],t=document.createElement("script"),r;(t.async=!0,t.type="text/javascript",t.crossorigin="anonymous","glassix-widget-script",r=t.cloneNode(),t.onload=u,t.src="",!document.getElementById(,i),t.onerror=f)})(widgetOptions)
<!-- End of Glassix Chat Widget -->

Event Types


The widget has been initialized.


The widget has been loaded into the DOM. This is the first event to fire.


The widget instance has been removed from both the memory and the DOM.


Fired when the chat box becomes visible (true) or hidden (false).
The isVisiblity parameter is passed. Its values are true/false.


Fired when a new ticket was created.
The nextTicketId parameter is passed with the ticket Id.



If you want more information on the ticket you can see it using the API get endpoint.


Fired when a message (inbound and outbound-only by human agents) is sent.


Fired when a badge is clicked. For example a WhatsApp badge.
The (protocolType, departmentIdentifier) parameters are passed.
The value of protocolType is one of the protocols here.
The value of departmentIdentifier is the means of communication for the department.


If the customer clicked on the WhatsApp badge:
protocolType = WhatsApp
departmentIdentifier = department's WhatsApp phone number