Skip to content

Surveys

Collect feedback directly on your storefront with customizable multi-question forms — NPS, ratings, multiple choice, free text. Surveys are designed in the dashboard; the tag fetches the active ones and shows the right survey when its trigger fires.

How surveys appear

On boot the tag fetches active surveys for your tenant from /analytics/surveys/active. A survey then shows when all of its targeting rules match:

  • URL — the current page matches target_url_pattern (substring, or a ~regex if it starts with ~).
  • Trigger — either on page view (no target_event), or right after a specific event is tracked (target_event).
  • Frequency — hasn't already been shown per its frequency rule.
  • Rollout — the visitor is in the rollout percentage (sticky per visitor).

Once matched, an optional delay_ms waits before showing.

Frequency

ValueMeaning
once_visitorShow at most once per visitor (persisted in localStorage).
once_sessionShow at most once per browser session.
alwaysShow every time the trigger fires.

Show a survey manually

Trigger any active survey by its key, regardless of targeting:

js
window.periscale.showSurvey("post_purchase_nps"); // returns true if found & shown

Close whatever survey is currently open:

js
window.periscale.dismissSurvey();

React to loaded surveys

Active surveys load asynchronously. Subscribe to know when they're ready — useful to drive a custom trigger button:

js
const off = window.periscale.onSurveys((surveys) => {
  console.log(`${surveys.length} surveys available`);
});
off(); // unsubscribe

Trigger on an event

Set a survey's target_event to checkout_complete, then when you track that event, the survey is evaluated automatically:

js
window.periscale.track("checkout_complete", { order_id: "1042" });
// → if a survey targets this event and the visitor qualifies, it appears

Question types

A survey is a sequence of questions. Each supports required, an optional description, and (for text) a placeholder / max_length.

TypeCapturesNotes
nps0–10Optional min_label / max_label.
rating1–maxicon: star (default) / heart / thumb.
single_choiceone optionoptions: string[].
multiple_choicearray of optionsOptional min_select / max_select.
short_textstring
long_textstringmax_length, multi-line.
emailstringValidated against an email pattern when required.
numbernumberOptional min / max.

Theming & screens

Each survey carries its own theme — primary_color, background_color, text_color, button_label, font_family, and show_branding. Optional welcome and thank-you screens bracket the questions. Position is one of popup_br (bottom-right, default), popup_bl, modal, or inline.

Where responses go

On submit, answers are POSTed to /analytics/surveys/respond with the survey id, distinct id, fingerprint, and page URL. Submission is best-effort and silently ignores network errors.

© Periscale