Installation
userpilotSettings Object
Getting Started
To use the SDK, ensure it is loaded on your page. Then, you can call the available methods on theuserpilot object.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
The Userpilot JavaScript SDK allows you to identify users, track events, trigger content, and manage sessions directly from your web application.
npm i userpilot
import { Userpilot } from 'userpilot'
Userpilot.initialize(app_token, userpilotSettings);
<script>
window.userpilotSettings = {token: app_token}
</script>
<script src="https://js.userpilot.io/sdk/latest.js"></script>
| key | Description | Example |
|---|---|---|
| token | Account App Token | NX-98ii14b |
| version | Pinned SDK Version | 1.730 |
| connection | Enable long-polling mode | polling | websocket |
| endpoint | API endpoint for when proxying | api.example.com/socket |
| domain | JS SDK domain for CNAME | js.example.com |
| pageview | Specifies what to collect from a URL | pathonly | withhash | fullurl |
| auto_props | Collecting auto properties | true | false |
| sri | Sub Resource Integrity value | sha384-AivuiHqNxK7LKiAbFB+8god8cikUQmz |
| auto_capture | Define autocapture privacy settings | See Element Privacy Settings |
| callbacks | Listen to events that occur on the SDK side | See Callbacks |
| integrations_interfaces | Define the integration interface | See Integrations Interfaces |
userpilot object.
userpilot.identify("123", {
name: "John",
email: "john@example.com",
created_at: "1519205055"
// Additional user properties
});
userpilot.anonymous();
userpilot.reload();
userpilot.reload({ url: 'https://example.com/hello' });
userpilot.track("invitedAgent", {
name: "Sam",
email: "sam@example.com"
});
userpilot.triggerById(17);
userpilot.on('completed', function(event) {
alert('Flow completed');
});
// Flow started
userpilot.on('started', (event) => { /* ... */ });
// Flow completed
userpilot.on('completed', (event) => { /* ... */ });
// Flow dismissed
userpilot.on('dismissed', (event) => { /* ... */ });
// Step interaction
userpilot.on('step', (event) => { /* ... */ });
| Method | Parameters | Description |
|---|---|---|
| identify | userId, properties? | Identify a user and set properties |
| anonymous | Unique session-based ID | |
| reload | options? | Reload Userpilot content |
| track | name, properties? | Track a custom event |
| triggerById | contentId | Show specific content |
| on | event, callback | Listen for Userpilot events |
| off | event | Remove event listener |
| once | event, callback | Listen for event once |
| end | End the current flow | |
| clean | Clear Userpilot storage | |
| destroy | Remove all Userpilot data and content | |
| suppress | Stop Userpilot operations on the SDK | |
| unsuppress | Resume Userpilot after suppression |
Was this page helpful?