Saving Survey Results and Advancing

Your Web View step can return a single answer, which will be saved in the survey results. This is done with the completeStep method of the MyDataHelps.js SDK:

MyDataHelps.completeStep(answer);

This requires your Web View steps to include the MyDataHelps.js SDK. See the JS SDK Getting Started page for more details.

Advancing to the Next Step

Posting an answer also continues to the next survey step.

Normal navigation/branching rules apply, allowing you to skip a web view step or advance to specific steps based on previous results.

Populating Custom Fields and Demographics

You can store the answer from a Web View step into a custom field or demographic field just as you can for any other step type. See Setting Custom Fields From Survey Answers or Setting Demographic Fields From Survey Answers .

Storing Complex Data

Answers from Web View steps are always saved in string format. However, if you have a complex answer you can use JSON.stringify to save a JSON object as a string.

Example

In this example, there is a single text box with an ID of “answer” where the user inputs their answer, and a “Continue” button that saves the answer and advances to the next step.

The script code gets the answer from the text box and then submits it as the step’s answer result.

Completing a Web View Step
<input id="Answer" type="text" placeholder="Test" />
<button onclick="postAnswer()">Continue</button>
<script>
function postAnswer() {
  var answerInput = document.getElementById("Answer");
  var answer = answerInput.value;
  MyDataHelps.completeStep(answer);
}
</script>
<input id="Answer" type="text" placeholder="Test" /> <button onclick="postAnswer()">Continue</button> <script> function postAnswer() { var answerInput = document.getElementById("Answer"); var answer = answerInput.value; MyDataHelps.completeStep(answer); } </script>