Skip to content

Events API

The widget exposes a JavaScript API that lets you control it and react to user actions directly from your site’s code.

Before the widget loads, window.Pliic is an array. You push commands onto it with push(). Once the widget finishes loading, the array is replaced by an object with its own push() method, and all queued commands are executed in order.

This pattern ensures you can register events even before the script finishes loading.

<script>
window.Pliic = window.Pliic || [];
window.Pliic.push(['on', 'suggestion:created', function(data) {
console.log('New suggestion:', data.title);
}]);
</script>
window.Pliic.push(['open']);
window.Pliic.push(['close']);
window.Pliic.push(['setTab', 'suggestions']);
window.Pliic.push(['setTab', 'support']);
window.Pliic.push(['on', 'widget:open', function() {
console.log('Widget opened');
}]);
EventPayloadDescription
widget:openThe widget panel was opened.
widget:closeThe widget panel was closed.
widget:tab-change{ tab: string }The active tab changed.
suggestion:created{ id: number, title: string }A new suggestion was submitted.
ticket:created{ id: number, ticket_number: string }A new ticket was submitted.
<script>
window.Pliic = window.Pliic || [];
window.Pliic.push(['on', 'widget:open', function() {
console.log('The user opened the widget');
}]);
window.Pliic.push(['on', 'widget:tab-change', function(data) {
console.log('Active tab:', data.tab);
}]);
window.Pliic.push(['on', 'suggestion:created', function(data) {
console.log('Suggestion #' + data.id + ': ' + data.title);
}]);
window.Pliic.push(['on', 'ticket:created', function(data) {
console.log('Ticket created:', data.ticket_number);
}]);
</script>
<script
src="https://pliic.com/widget/v1.js"
data-app-key="YOUR_APP_KEY"
async
defer
></script>