Skip to main content

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

EventFires when
readySDK has finished initializing and is ready to use
identifyA user has been identified via DAP('identify', ...)
errorAn SDK error occurs

Flow Events

EventFires when
flow:startA guided flow begins
flow:completeA user finishes all steps of a flow
flow:dismissA user dismisses a flow before completing it
step:viewA flow step is displayed to the user
step:completeA user completes a single flow step

Content Events

EventFires when
content:loadedContent items have been fetched from the server
content:renderedA content item (tooltip, beacon, survey, etc.) is rendered on screen
content:render_failedA content item failed to render (e.g., target selector not found)

Journey Events

EventFires when
journey:startA user is enrolled in a multi-step journey
journey:completeA user completes all steps of a journey

Interaction Events

EventFires when
page_viewA page navigation or URL change is detected
clickAn interactive element is clicked
form_submitA form is submitted
form_field_interactionA form field is interacted with (focus, input)
scroll_milestoneA scroll depth milestone is reached (25%, 50%, 75%, 100%)
rage_clickA rage click is detected (rapid repeated clicks on an element)
dead_clickA dead click is detected (click on a non-interactive element with no visible response)

Survey Events

EventFires when
survey:responseA user submits a survey or NPS response

Experiment Events

EventFires when
experiment:conversionA 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', ...).