Add a small amount of JavaScript to a question to read or set answers, read URL parameters, change variables, or react to the respondent's input. Custom JS is opt-in per question and is always sandboxed — see Limits & Security for what it can and cannot do.
Status: the JavaScript runtime API (
window.Intuify.survey.*) is exposed to the respondent page and the builder preview. Authoring the per-questiononLoad/onSubmitscript editor is shipping behind a follow-up release; until then, you can use the runtime API from external tools (browser console, embed wrappers, Tag Manager). The reference pages below describe the public surface that ships today.
When to use custom JS#
- Pre-fill an answer from URL parameters.
- Read another question's answer and display it elsewhere on the page.
- Set a survey variable based on a calculation.
- Translate a Qualtrics widget that you migrated to Intuify.
For most use cases, the no-code features cover you:
| Need | Use this instead |
|---|---|
| Show/hide a question | Display Logic |
| Send respondents down a path | Skip Logic |
| Reuse a prior answer in question text | Piping |
| Translate the question UI | Multi-language |
| Talk to an external service | Web Service block (flow editor) |
Reach for custom JS only when you've ruled the above out.
How it works#
Each survey page gets a fresh window.Intuify object. The full API
lives on window.Intuify.survey:
// Read the current question's text after piping
const text = window.Intuify.survey.getQuestionText("q_1");
// Pre-fill an answer
window.Intuify.survey.setResponse("q_2", "red");
// Read URL params (e.g. ?source=email)
const { urlParams } = window.Intuify.survey.getEmbeddedData();
console.log(urlParams.source);
The three legacy variable shortcuts still work for backward compatibility:
window.Intuify.setVariable("score", 42);
window.Intuify.getVariable("score"); // 42
window.Intuify.getAllVariables(); // { score: 42, ... }
See API reference for the full method list and Examples for ready-to-use snippets.
Lifecycle (planned)#
Once the per-question onLoad / onSubmit editor ships:
| Hook | Fires | Typical use |
|---|---|---|
onLoad | When the question is shown | Read URL params, default answers |
onSubmit | When the respondent clicks Next | Validate, set variables, fork branches |
Text/Graphic display blocks support only onLoad (there's no response
to submit).
Preview vs. live#
The runtime API is identical between the builder preview and the live respondent page, with two caveats:
- Preview survey variables aren't persisted (they reset each preview run).
- The server-driven respondent runtime treats
setVariableas a no-op for now — variable writes from custom JS land in the next phase alongside an engine round-trip endpoint.
Either way, every getter (getQuestionText, getChoices, getResponse,
getMetadata, etc.) works the same in both environments. Test in
preview before going live.
Migrating from Qualtrics#
If you're porting a Qualtrics question that used this.questionText,
getChoices(), Qualtrics.SurveyEngine.setEmbeddedData(), etc., the
quick translation:
| Qualtrics | Intuify |
|---|---|
this.getChoices() | Intuify.survey.getChoices(questionId) |
this.questionText | Intuify.survey.getQuestionText(questionId) |
Qualtrics.SurveyEngine.getEmbeddedData("x") | Intuify.survey.getVariable("x") (or getEmbeddedData().urlParams.x) |
Qualtrics.SurveyEngine.setEmbeddedData("x", v) | Intuify.survey.setVariable("x", v) |
this.getQuestionInfo().QuestionType | Intuify.survey.getQuestion(id)?.type and .pluginType |
getSelectedChoices() (selected ids) | Intuify.survey.getResponse(id) |
For full plugin payloads (themes, columns, plugin config) call
Intuify.survey.getQuestionPayload(id) — that returns the same shape
your widget iframe already receives.
Related guides#
Was this page helpful?