Intuify

Intuify

Documentation

Logic & flow3 min read

Custom JavaScript

Add small JavaScript snippets to read or set answers, change variables, and react to respondent input.

On this page (6 sections)

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-question onLoad / onSubmit script 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:

NeedUse this instead
Show/hide a questionDisplay Logic
Send respondents down a pathSkip Logic
Reuse a prior answer in question textPiping
Translate the question UIMulti-language
Talk to an external serviceWeb 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:

js
// 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:

js
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:

HookFiresTypical use
onLoadWhen the question is shownRead URL params, default answers
onSubmitWhen the respondent clicks NextValidate, 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:

  1. Preview survey variables aren't persisted (they reset each preview run).
  2. The server-driven respondent runtime treats setVariable as 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:

QualtricsIntuify
this.getChoices()Intuify.survey.getChoices(questionId)
this.questionTextIntuify.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().QuestionTypeIntuify.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.


Was this page helpful?