JavaScript SDK
Once the widget script loads, it attaches a global window.Trackelio object. Use this SDK to control the widget programmatically, identify users, and react to widget events.
Methods
Section titled “Methods”identify
Section titled “identify”Associate the current session with a known user. Identified users skip the guest name/email fields in the Feedback module.
window.Trackelio.identify({ user_id: 'usr_12345', email: 'jane@example.com', name: 'Jane Smith', plan: 'pro', // custom attribute company: 'Acme Inc.', // custom attribute});You can pass any additional key-value pairs as custom attributes. These are stored alongside the submission for filtering in the dashboard.
Open the widget panel. Optionally specify a module to navigate to directly.
window.Trackelio.open();window.Trackelio.open({ module: 'nps' });Valid module values: feedback, nps, csat, surveys, messenger, announcements.
Close the widget panel. The trigger button remains visible.
window.Trackelio.close();Show the trigger button if it was previously hidden.
window.Trackelio.show();Hide the trigger button and close the panel if it is open.
window.Trackelio.hide();prefill
Section titled “prefill”Pre-fill fields in the Feedback module. Useful for contextual feedback links.
window.Trackelio.prefill({ module: 'feedback', title: 'Problem with checkout', description: 'The payment button is unresponsive on mobile.',});| Parameter | Type | Description |
|---|---|---|
title | string | Pre-fill the title field. |
description | string | Pre-fill the description field. |
module | string | Switch to this module when the panel opens. |
setConfig
Section titled “setConfig”Override widget configuration at runtime. Changes persist for the current page session.
window.Trackelio.setConfig({ position: 'bottom-left', panel_width: 480, branding: { accent_color: '#10B981', },});See Configuration and Theming for available options.
on / off
Section titled “on / off”Subscribe to or unsubscribe from widget events.
function handleSubmit(data) { console.log('Feedback submitted:', data);}
window.Trackelio.on('submit', handleSubmit);window.Trackelio.off('submit', handleSubmit);See the Events section below for the full list of event names.
Clear all user data (identity and session) and close the panel. The trigger button remains visible.
window.Trackelio.reset();destroy
Section titled “destroy”Remove the widget entirely from the DOM. This detaches the trigger button, panel, and all event listeners. After calling destroy(), window.Trackelio is no longer functional.
window.Trackelio.destroy();Events
Section titled “Events”Register event listeners with window.Trackelio.on(event, handler). The handler receives an event-specific data object.
| Event | Fires when |
|---|---|
open | The widget panel is opened. |
close | The widget panel is closed. |
submit | A feedback submission is completed. |
screenshot | A screenshot is captured. |
identify | A user is identified via identify(). |
reset | User data is cleared via reset(). |
messenger:start | A new Messenger conversation begins. |
messenger:message | A message is sent or received in Messenger. |
nps:submit | An NPS score is submitted. |
csat:submit | A CSAT rating is submitted. |
module:change | The user switches to a different module tab. |
survey:submit | A survey response is submitted. |
Example
Section titled “Example”window.Trackelio.on('nps:submit', (data) => { console.log('NPS score:', data.score); console.log('Comment:', data.comment);});
window.Trackelio.on('module:change', (data) => { console.log('Switched to module:', data.module);});