Zum Inhalt springen

JavaScript-API

Nach dem Laden von feedback.js steht window.usertraxSurveys bereit (wenn Umfragen für den Auth-Key verfügbar sind).

// Popup programmatisch öffnen (ohne Trigger)
usertraxSurveys.open(42);
// Popup schließen
usertraxSurveys.close();
// Inline in einen Container mounten
usertraxSurveys.mount('#survey-slot', 42);
usertraxSurveys.mount(document.getElementById('survey-slot'), 42);
// Inline entfernen
usertraxSurveys.unmount('#survey-slot');
<div data-usertrax-survey="42"></div>

Beim Boot und bei SPA-Navigation mountet das Script automatisch alle Elemente mit data-usertrax-survey.

  • popup — Trigger-Engine (URL → Sampling → Delay → Exit-Intent). Pro Pageview höchstens eine Auto-Popup-Umfrage.
  • inline — nur Mount/API/data-usertrax-survey, kein Auto-Trigger.

Nach Complete oder Dismiss speichert das Script einen Cooldown in localStorage (usertrax_survey_cooldown:{id}), Dauer konfigurierbar pro Umfrage (cooldown_days).