ExitPoll
Overview
ExitPoll allows you to serve qualitative survey questions to your users.
This only requires a few lines of code and some question creation on your Cognitive3D dashboard. This page will walk you through the process of enabling and configuring an ExitPoll in your application.
Creating an ExitPoll
ExitPoll Hooks and Question Sets are created on the Cognitive3D Dashboard. A Hook is requested from the application during the experience and receives a Question Set as a response. This allows you to use change Question Sets without having to rebuild or redeploy your app.
The following example will display a Question Set.
1. Create ExitPoll Question Set and Hook
Before using ExitPoll, create a question set on the Dashboard. You can do this under Manage ExitPolls in Project Settings, accessible via the gear icon in the top-right menu bar.
Next, you will need a Hook to display the ExitPoll in your experience. The hook will be your unique identifier to retrieve a set of questions from the backend. Click on Manage Hooks, create a new hook, and link it to your question set as shown below.
For more details, visit the Dashboard Exitpoll page.
Step 2: Request Question Set from your app
Then on your project, use the Hook name we created to request the assigned Question Set.
The c3d.getQuestionSet()
method will return an object with the questions.
You can also use c3d.getQuestionSetString();
which returns a string of the questions.
let myHook = 'app_test_js';
c3d.requestQuestionSet(myHook)
.then(()=>{
let object = c3d.getQuestionSet(); // Returns json
myVoiceReponse = myMicrophoneReponse(); // Voice reponses require a .wav file encoded in base64 format.
// After receiving the response, you can add answers to the active Question Set by calling addAnswer:
c3d.exitpoll.addAnswer('BOOLEAN', 1); // Question #1 answer is True. Our system counts "1" as True and "0" as False.
c3d.exitpoll.addAnswer('HAPPYSAD', 1); // Question #2 answer is "Happy"
c3d.exitpoll.addAnswer('THUMBS', 1); // Question #3 answer is "Thumbs up"
c3d.exitpoll.addAnswer('MULTIPLE', 2); // Question #4 answer is answer #3, "awesome" (json example available below)
c3d.exitpoll.addAnswer('SCALE', 7); // Question #5 answer is 7/10
c3d.exitpoll.addAnswer('VOICE', myVoiceReponse); // Question #6 answer is a base64 string encoded from a .wav file
c3d.exitpoll.sendAllAnswers(); // Send all answers to server
});
An example JSON you could get from the c3d.getQuestionSet();
method:
{
"id": "app_test_js:1",
"name": "app_test_js",
"customerId": "someCustomerId",
"status": "active",
"title": "Welome 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": {
"end": 2,
"start": 0
}
},
{
"type": "VOICE",
"title": "voice",
"maxResponseLength": 20
}
]
}
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.