Exit Poll
Exit Polls are short, in-experience surveys you can serve to participants at a moment of your choosing — usually the end of a session, but anywhere in the flow works. Each poll is defined on the Cognitive3D dashboard as a Question Set and requested from the SDK by a Hook name, so you can change what participants are asked without re-deploying your app.
The Exit Poll API is the same across every framework integration. Presenting the questions is up to you — the SDK fetches the question set and submits answers, but you render the UI.
Authoring the Poll
Before any of the SDK calls will return anything useful, set up the poll on the dashboard:
- Create a Question Set. From the dashboard, open Project Settings (gear icon, top-right) → Manage ExitPolls. Add the questions you want and save.
- Create a Hook. Still under Project Settings, open Manage Hooks, add a new hook, and link it to the question set you just created. The hook's name is what the SDK uses to fetch it.
More detail is on the Dashboard Exit Poll page.
Question Types
A question set can contain any mix of the following. The type values come back in the question JSON and determine the UI you render.
| Dashboard type | Meaning | Typical answer value |
|---|---|---|
BOOLEAN |
Yes/No | 1 for true, 0 for false |
HAPPYSAD |
Happy / Sad face | 1 for happy, 0 for sad |
THUMBS |
Thumbs up / down | 1 for up, 0 for down |
SCALE |
N-point numerical scale | integer in the scale range |
MULTIPLE |
Multiple choice | 0-indexed integer of the chosen answer |
VOICE |
Voice response | base64-encoded .wav string |
Requesting a Question Set
Once a session is active, request the question set by its hook name:
const myHook = "app_test_js";
c3d.exitpoll.requestQuestionSet(myHook)
.then(() => {
// The question set is now loaded and ready to render.
const questions = c3d.exitpoll.getQuestionSet(); // parsed JSON
// const questionsString = c3d.exitpoll.getQuestionSetString(); // same, as a string
renderYourPollUI(questions);
})
.catch(err => {
console.error("Exit poll request failed:", err);
});
Note
requestQuestionSet only resolves while a session is active. If no session has been started, the call rejects. Request the poll after c3d.startSession(...) has resolved.
An example of the JSON you'll get back:
{
"id": "app_test_js:1",
"name": "app_test_js",
"customerId": "someCustomerId",
"status": "active",
"title": "Welcome to the JS SDK",
"version": 1,
"questions": [
{ "type": "BOOLEAN", "title": "Do you like Javascript?" },
{ "type": "HAPPYSAD", "title": "How does Javascript make you feel?" },
{ "type": "THUMBS", "title": "Javascript. Thumbs up or down?" },
{
"type": "MULTIPLE",
"title": "How would you describe Javascript?",
"answers": [
{ "icon": null, "answer": "nice" },
{ "icon": null, "answer": "cool" },
{ "icon": null, "answer": "awesome" },
{ "icon": null, "answer": "the best" }
]
},
{
"type": "SCALE",
"title": "How much do you like scales out of 10?",
"minLabel": "1",
"maxLabel": "10",
"range": { "start": 0, "end": 2 }
},
{
"type": "VOICE",
"title": "voice",
"maxResponseLength": 20
}
]
}
Submitting Answers
For each question, call addAnswer(type, value). The type string picks the answer's dashboard category; the value is whatever the participant chose. When you've added an answer for every question, call sendAllAnswers() to submit.
c3d.exitpoll.addAnswer("boolean", 1); // Q1: true
c3d.exitpoll.addAnswer("happySad", 1); // Q2: happy
c3d.exitpoll.addAnswer("thumbs", 1); // Q3: thumbs up
c3d.exitpoll.addAnswer("multiple", 2); // Q4: chose answer index 2 ("awesome")
c3d.exitpoll.addAnswer("scale", 7); // Q5: 7 out of 10
c3d.exitpoll.addAnswer("voice", myVoiceBase64); // Q6: base64-encoded .wav
c3d.exitpoll.sendAllAnswers();
Type strings are case-sensitive
Pass the answer type as one of exactly: "happySad", "boolean", "thumbs", "scale", "multiple", "voice". Anything else (including the uppercase dashboard labels like "BOOLEAN") is treated as an unknown type and the answer won't be categorized correctly on the dashboard.
sendAllAnswers() accepts an optional 3D position ([x, y, z]) — handy for pinning the answer to where the participant was standing when they filled out the poll:
c3d.exitpoll.sendAllAnswers([camera.position.x, camera.position.y, camera.position.z]);
Clearing Between Polls
After sendAllAnswers() resolves, the active question set is cleared automatically, so you can request another hook and run the flow again. If you want to cancel a poll mid-way — the participant quit before finishing — call c3d.exitpoll.clearQuestionSet() to reset without sending.
If you have a question or any feedback about our documentation please use the Intercom button (purple circle) in the lower right corner of any web page or join our Discord.