Working with widget and online chat events
- Knowledge base
- Widget
- Working with widget and online chat events
Processing widget and online chat events
You can tune interaction between the functionality widget and online chat and features of your site, by processing JavaScript events, initiated by widget code.
3 types of events are available:
- initialize_widget - is triggered after widget is loaded on the site page;
- initialize_client - is triggered, when client opens dialog window in online chat:
- if pre-chat survey is not set up - then just after the online chat dialog window is opened;
- if pre-chat survey is set up - then just after the user enters survey data and the dialog window is opened.
- first_client_message - is triggered once, when first message from client is sent in online chat dialog.
Sample scenarios to implement:
- When a client opens a dialog window in online chat, section Useful info on your site is highlighted;
- When a client sends the first message in online chat, banner with special offer is shown on your site.
Javascript code sample:
document.addEventListener('first_client_message', ShowBannerFunction)
Initiating widget and online chat events
You can tune interaction between the functionality widget and online chat and features of your site, by initiating JavaScript events, executed by widget code.
2 type of events is available:
- popups:close — this event performs the closure of online chat dialog window and additional pop-up windows (e.g., Viber QR-code window).
Sample scenario to implement:
- When clients clicks callback button, online chat window is closed.
Javascript code sample:
document.dispatchEvent(new CustomEvent("popups:close"))
- popups:open — this event performs the opening of online chat dialog window and additional pop-up windows (e.g., Viber QR-code window).
Sample scenario to implement:
- When clients clicks callback button, online chat window is opened.
Javascript code sample:
document.dispatchEvent(new CustomEvent("popups:open"))
Related articles
Widget
Ask a question