API Reference

SDK methods and auto-tracked events.

SDK Methods

HtmlAI.init(options)

Initialize with custom config (apiKey, apiBaseUrl, trackingDomain, debug)

HtmlAI.track(eventName, componentId?, properties?)

Track custom events with optional component context and properties

HtmlAI.getUser()

Returns { user_id, session_id, global_uid }

HtmlAI.onSync(callback)

Callback when cross-site identity sync completes

HtmlAI.flush()

Force send all queued events immediately

Auto-tracked Events

The SDK automatically tracks these behavioral signals:

page_viewed

Page load with URL and referrer

scroll_depth_reached

Scroll depth percentage

scroll_fast

Rapid scrolling (>500px)

scroll_direction_change

Direction changes

rage_click

3+ clicks in 500ms

dead_click

Click on non-interactive element

mouse_hesitation

Mouse idle for 2+ seconds

hover

Hover on data-track-hover elements

tab_hidden / tab_visible

Tab visibility changes

component_viewed

ai-opt component in view

For REST API documentation, see the FastAPI docs at /docs on the API server.