Trigger Engine
Triggers let you show surveys automatically in response to events that happen inside your application. This is one of ResponseDock's core differentiators — no manual sharing needed.
How It Works
- Your app calls
ResponseDock.track("event_name", payload), or the SDK emits an automatic event such as$pageview - The SDK sends the event to the ResponseDock API, together with the identified user or the visitor's anonymous id
- The API evaluates the active trigger rules for that event name and environment, in priority order
- Conditions, schedule, sampling, holdout and frequency rules decide which surveys are eligible
- The API records a display for the first eligible survey and returns the eligible surveys
- The SDK opens the first survey in a modal, unless another survey is already open
Tracking Events
import { ResponseDock } from 'https://survey.responsedock.com/sdk/0.2/index.js';
ResponseDock.init({
projectKey: 'pk_live_xxxx',
});
ResponseDock.identify({
externalUserId: currentUser.id, // optional; anonymous visitors get a persisted anonymousId
});
// Fire a named event with context payload
ResponseDock.track('match_completed', {
matchId: 'match_789',
teamId: 'team_123',
result: 'win',
sport: 'football',
});Every event also carries pageUrl, pagePath, pageTitle and referrer, so conditions can target pages without extra code. Values passed as the third context argument are matched as context.<key>, and identify traits as trait.<key>.
Automatic Events
The browser SDK can emit events for you. They are off by default; enable the ones you need with the autoTrack option of init() and create trigger rules for their event names:
ResponseDock.init({
projectKey: 'pk_live_xxxx',
autoTrack: { pageViews: true, exitIntent: true, scrollDepth: [50, 90], delaySeconds: [30] },
});| Event name | Properties | Fires |
|---|---|---|
$pageview | page properties | On load and on every SPA navigation |
$scroll_depth | depth (percent) | Once per page for each threshold reached |
$time_on_page | seconds | Once per page after each delay |
$exit_intent | none | Once per page when a desktop pointer leaves through the top of the window |
For example, a trigger on $scroll_depth with the conditions depth equals 90 and pagePath contains /blog/ asks readers who finish an article. See the browser SDK reference for details.
Creating a Trigger
- Open Audience targeting in the dashboard sidebar
- Click Create target
- Pick the survey and set the event name (must match what your SDK sends)
- Add optional conditions (e.g.,
result equals win) - Set the sample, holdout, frequency and limits
- Choose the environment, then save
Priority and an active date window can be set through the Triggers API.
Trigger Fields
| Field | API name | Description |
|---|---|---|
| Event name | eventName | Exact name of the SDK event (e.g. match_completed or $pageview) |
| Conditions | conditions | Optional rules evaluated against the event payload; all must match |
| Priority | priority | Higher number is evaluated first when multiple surveys match. Default 0 |
| Frequency | frequencyRule | How often the same person may see the survey; see below. Default once per user |
| Context property | contextKey | For once per context: the event property that identifies the context, e.g. matchId |
| Days between displays | frequencyDays | For once every X days: 1 to 365. Default 30 |
| Cooldown seconds | cooldownSeconds | Minimum time between displays of this survey to the same person |
| Max displays per user | maxDisplaysPerUser | Max times a person can be shown this survey; empty for no limit |
| Max responses per user | maxResponsesPerUser | Max completed responses per person; empty for no limit |
| Eligible-user sample | sampleRate | Share of eligible people who can see the survey, 0 to 1. Default 1 |
| Measurement holdout | holdoutRate | Share of people never shown the survey, kept as a control group, 0 to 0.95. Default 0 |
| Active dates | startsAt, endsAt | Optional start/end window for the trigger |
| Environment | environment | PRODUCTION, STAGING or DEVELOPMENT; must match the SDK's environment |
| Active | isActive | Inactive triggers are never evaluated |
Condition Operators
equals | not_equals | contains | not_contains greater_than | less_than | exists | not_exists in_list | not_in_list
Frequency Rules
| Rule | Behavior |
|---|---|
ONCE_PER_USER | Keep asking until the user completes a response, then never again (the default) |
ONCE_EVER | Same check as once per user: stops after the user's first completed response |
ONCE_PER_CONTEXT | Show once per user for each value of contextKey in the event (e.g. once per match) |
ONCE_PER_X_DAYS | At most one display every frequencyDays days per user (30 when unset) |
UNLIMITED | No frequency rule; only cooldown and the per-user limits apply |
For ONCE_PER_CONTEXT, contextKey names an event property; matchId also finds a value sent as context.matchId. Events that don't carry the property share a single context, so the survey shows only once across all of them.
How Frequency Is Counted
Every rule is evaluated per person: the identified externalUserId when there is one, otherwise the anonymous id the browser SDK keeps for each visitor.
- Response-based rules (
ONCE_PER_USER,ONCE_EVERandmaxResponsesPerUser) count completed responses only. Someone who closed the survey halfway can be asked again. - Display-based rules (
cooldownSeconds,ONCE_PER_CONTEXT,ONCE_PER_X_DAYSandmaxDisplaysPerUser) count displays recorded by the server. A display is recorded when/sdk/eventsreturns a survey, so the caps hold even if the page closes before the survey loads. - Anonymous visitors are capped by displays: their responses can't be linked to the anonymous id, so for them the response-based rules count displays instead. An anonymous visitor who has been shown a
ONCE_PER_USERsurvey is not asked again. - Events with neither an
externalUserIdnor an anonymous id cannot be capped.
Sampling and Holdouts
Each person gets a stable cohort per trigger, so the same person is always inside or outside the sample. People in the holdout never see the survey; the sample then applies to everyone else. A visitor's anonymous id is cleared by ResponseDock.reset(), after which they get a new cohort.
Multiple Surveys Matching
If multiple triggers match the same event, ResponseDock evaluates them by priority, highest first, and the SDK opens the first eligible survey. Only that survey gets a display recorded. A survey a trigger opens never replaces one that is already open.
Debugging
The debugger on the Audience targeting page evaluates an event name, user id and properties against every trigger and explains why each one would or would not show (inactive, schedule, conditions, holdout, sample or frequency). It doesn't record a display.
Use environment: "development" in init() and DEVELOPMENT triggers during testing to avoid showing surveys to real users.