SDK Events
The SDK emits events at key moments during its lifecycle. Use event listeners to react to user interactions, flow progress, and SDK state changes within your application.
Subscribing to Events
Register a listener with DAP('on', eventName, callback) and remove it with DAP('off', eventName, callback).
function onFlowStart(data) {
console.log("Flow started:", data);
}
// Subscribe
DAP("on", "flow:start", onFlowStart);
// Unsubscribe (pass the same function reference)
DAP("off", "flow:start", onFlowStart);
You can register listeners before init completes -- they will fire as soon as the corresponding event occurs.
Available Events
Lifecycle Events
| Event | Fires when |
|---|---|
ready | SDK has finished initializing and is ready to use |
identify | A user has been identified via DAP('identify', ...) |
error | An SDK error occurs |
Flow Events
| Event | Fires when |
|---|---|
flow:start | A guided flow begins |
flow:complete | A user finishes all steps of a flow |
flow:dismiss | A user dismisses a flow before completing it |
step:view | A flow step is displayed to the user |
step:complete | A user completes a single flow step |
Content Events
| Event | Fires when |
|---|---|
content:loaded | Content items have been fetched from the server |
content:rendered | A content item (tooltip, beacon, survey, etc.) is rendered on screen |
content:render_failed | A content item failed to render (e.g., target selector not found) |
Journey Events
| Event | Fires when |
|---|---|
journey:start | A user is enrolled in a multi-step journey |
journey:complete | A user completes all steps of a journey |
Interaction Events
| Event | Fires when |
|---|---|
page_view | A page navigation or URL change is detected |
click | An interactive element is clicked |
form_submit | A form is submitted |
form_field_interaction | A form field is interacted with (focus, input) |
scroll_milestone | A scroll depth milestone is reached (25%, 50%, 75%, 100%) |
rage_click | A rage click is detected (rapid repeated clicks on an element) |
dead_click | A dead click is detected (click on a non-interactive element with no visible response) |
Survey Events
| Event | Fires when |
|---|---|
survey:response | A user submits a survey or NPS response |
Experiment Events
| Event | Fires when |
|---|---|
experiment:conversion | A conversion event is recorded for an experiment variant |
Event Payloads
Each callback receives a payload object. Examples:
DAP("on", "identify", (data) => {
// data: { userId: 'user-42', traits: { role: 'admin' } }
});
DAP("on", "flow:start", (data) => {
// data: { flowId: 'flow_abc123' }
});
DAP("on", "rage_click", (data) => {
// data: { element: HTMLElement, count: 5 }
});
DAP("on", "dead_click", (data) => {
// data: { element: HTMLElement, selector: string }
});
DAP("on", "journey:start", (data) => {
// data: { journeyId: 'journey_xyz', name: 'Onboarding' }
});
DAP("on", "content:rendered", (data) => {
// data: { contentId: 'tooltip_abc', type: 'tooltip' }
});
DAP("on", "survey:response", (data) => {
// data: { surveyId: 'survey_123', answers: [...] }
});
Auto-Tracked Events
When autoTrack is enabled (the default), the SDK automatically captures the following without any additional code:
- Page views -- recorded on each navigation or URL change
- Clicks -- captured on interactive elements
- Scroll depth -- milestone percentages as the user scrolls down a page
- Rage clicks -- rapid repeated clicks on the same element, often indicating user frustration
- Dead clicks -- clicks on elements that produce no visible response, suggesting broken or confusing UI
Disable auto-tracking by passing autoTrack: false in the init config:
DAP("init", {
tenantKey: "YOUR_TENANT_KEY",
autoTrack: false,
});
When auto-tracking is disabled, you can still send events manually with DAP('track', ...).