Skip to main content

Options


Example: Handling Callbacks

Render callback

Register on_render in window.userpilotSettings.callbacks before the SDK script loads. It receives one event object for banners, cards, flow steps, spotlights, checklists, surveys, NPS, and the resource center. Every event includes type, id, and the mounted host-page element. Flow events use the step ID as id and also include flow_id. Survey events can run for each displayed module and include module_id.
Banner and card callbacks run after the element is mounted and sized, immediately before its iframe becomes visible. height is the element’s getBoundingClientRect().height and excludes outside margins. The height can change later, so use a ResizeObserver on element if the host layout must keep tracking it. on_render is separate from userpilot.on('render', ...), which listens to flow events.

Type definitions


Troubleshooting

  • “My callback doesn’t fire” – Ensure the SDK is initialized with callbacks defined before events occur.
  • “Socket events not showing” – Verify network connections and channel join logic.
  • “Autocapture callback too noisy” – Combine with excluded_elements or masked_elements to reduce unwanted triggers.