API
These are the public methods of the DeepdotsPopups class. They cover everything a host application needs to mount the SDK, react to popups, and fire business events.
init(config)
Section titled “init(config)”Initializes the SDK and fetches the popup definitions from Deepdots.
popups.init({ mode: 'server', apiKey: 'YOUR_PUBLIC_API_KEY', userId: 'customer-123', // optional});| Field | Required | Description |
|---|---|---|
mode | yes | Always 'server' for customer integrations. |
apiKey | yes | Your Deepdots public API key. |
userId | no | Identifier sent with every popup event. |
autoLaunch()
Section titled “autoLaunch()”Starts the triggers derived from the definitions loaded during init(). Call once after init().
popups.autoLaunch();triggerEvent(eventName)
Section titled “triggerEvent(eventName)”Fires a custom business event. Any popup in Deepdots configured with an event trigger that matches eventName will be shown (subject to cooldowns and targeting).
popups.triggerEvent('checkout_completed');See Triggers → event for details.
show({ surveyId, productId })
Section titled “show({ surveyId, productId })”Shows a popup directly, bypassing triggers. Cooldowns and route targeting are still respected.
popups.show({ surveyId: 'survey-home-001', productId: 'product-main',});showByPopupId(popupId)
Section titled “showByPopupId(popupId)”Same as show(), but you address the popup by its Deepdots id instead of its survey/product pair.
popups.showByPopupId('popup-home-5s');on(event, listener) / off(event, listener)
Section titled “on(event, listener) / off(event, listener)”Subscribe to the SDK events: popup_shown, popup_clicked, survey_completed.
const onShown = (event) => analytics.track('popup_shown', event);
popups.on('popup_shown', onShown);popups.off('popup_shown', onShown);See Events for the full payload shape.