Surveys
Surveys ask people questions inside your app: an NPS score after onboarding, a rating after checkout, or an open question about a new feature. Build them under Surveys. The SDK tells your app which surveys a person should see, and your app shows them in its own UI.
1. Build the survey
Questions— Single choice, multiple choice, NPS (0–10), rating (1–5), short text or long text. Mark any question as required.Environment— Production, staging or development; it must match the environment your app initializes the SDK with.All Users— Everyone is eligible.Matching User Property— Only people whose property equals a value, for example plan = pro. TraceIQ compares against the properties you pass, or the person’s identify() traits.Trigger on Specific Event— Only shown when your app asks for surveys right after that event, by passing its name.
Save Draft keeps it hidden. Publish Survey makes it live. A person who answers or dismisses a survey is never offered it again.
2. Show it in your app
import { traceiq } from 'traceiq-sdk-js';
// After onboarding finishes, for example
const [survey] = await traceiq.surveys.getEligibleSurveys({ eventName: 'onboarding_finished' });
if (survey) {
openSurveyModal(survey); // render survey.questions with your own components
traceiq.surveys.recordImpression(survey.id);
}
// When the person closes it without answering
traceiq.surveys.recordDismissal(survey.id);
// When they submit
await traceiq.surveys.submitResponse(survey.id, [
{ questionId: 'q_nps', questionType: 'nps', prompt: 'How likely are you to recommend us?', score: 9 },
{ questionId: 'q_why', questionType: 'long_text', prompt: 'What could be better?', answerText: 'Faster exports' }
]);Call identify() before asking for surveys so property targeting can use the person's traits and their answers are linked to their profile. Surveys are built into the browser SDK; from other platforms use POST /v1/surveys/eligible, /impression, /dismiss and /response with your write key.
3. Read the results
Each survey's page shows impressions, responses and the response rate, a breakdown per question (option counts, the average rating, the NPS score with promoters, passives and detractors) and the latest text answers.

