JavaScript API
Global methods available after loading the widget script.
Respondo.init(config)#
Initializes and mounts the widget. Must be called once. Returns the widget instance.
const widget = Respondo.init({
agentId: 'YOUR_AGENT_ID'
});Respondo.identify(identity)#
Attaches user identity to the current session. Call after login.
Respondo.identify({
email: 'user@example.com',
name: 'John Doe',
userId: 'usr_123',
userHash: 'hmac_sha256_signature', // optional, for identity verification
metadata: { plan: 'pro' },
properties: { // custom contact properties
account_type: 'enterprise', // keys defined in Agent Settings
region: 'eu-west'
}
});Respondo.track(name, properties?)#
Records a client-side event for the current visitor (e.g. purchase, plan upgrade). Events can start event-triggered Tours and count toward tour goals. Best-effort delivery with keepalive, so events fired right before navigation (checkout redirect) still arrive. Call after init().
Respondo.track('purchase_completed', {
plan: 'pro',
amount: 49
});Respondo.destroy()#
Removes the widget from the page. Useful for SPAs when navigating to pages where the widget should not appear. It does not clear the visitor's identity or stored conversation — for logout, use Respondo.reset().
// Remove widget from the page
Respondo.destroy();
// Reinitialize later if needed (resumes the same conversation)
Respondo.init({ agentId: 'YOUR_AGENT_ID' });Respondo.reset()#
Logout / shared-device handoff. Clears the anonymous visitor id, stored conversation, and session token from the browser, revokes the session token server-side so copies of it stop working, and re-mounts a fresh anonymous widget. Call this from your app's logout hook.
// On logout — wipe identity, conversation and session, start fresh
Respondo.reset();Automatic Data Collection
The widget automatically captures and stores the following with each conversation:
| Data | Source |
|---|---|
| Client IP | HTTP headers |
| Browser / OS | User-Agent header |
| Language | Accept-Language header |
| Timezone | Intl API (JavaScript) |
| Page URL | window.location |
| Referrer | Referer header |