Class: Survey

Overview

Represents Visitor Survey that can be used to respond to the Survey

Property Summary

(Array<SurveyQuestion>) questions

See SurveyQuestion for more info

Questions format

{
  "questions":[
    {
      "id":4,
      "type":"scale",
      "title":"The dealership"
    },
    {
      "id":5,
      "type":"boolean",
      "title":"This operator"
    },
    {
      "id":6,
      "type":"text",
      "title":"Other Thoughts"
    },
    {
      "id":7,
      "type":"single_choice",
      "title":"What was the order value",
      "choices": [
        {id: 2340, title: "$0-100"},
        {id: 2341, title: "$101-200"},
        {id: 2342, title: "$200+"}
      ],
    }
  ]
}

Variables Summary

QUESTION_TYPES =
{
  BOOLEAN: "boolean",
  SCALE: "scale",
  TEXT: "text",
  SINGLE_CHOICE: "single_choice"
}

Question types

  • boolean - expects a JS boolean as a response
  • scale - expects an Integer from 1 to 5 as a response
  • single_choice - expects a choice ID as a response
  • text - expects a String as a response

Instance Method Summary

Instance Method Details

# (Promise) respond(answers)

Respond to survey

Question response types

See Survey.QUESTION_TYPES for required response types

Examples:

Respond to Survey

var engagementRequest = salemove.requestEngagement('text');

engagementRequest.engagementPromise.then(function(engagement) {
  engagement.addEventListener(engagement.EVENTS.END, function() {
    var gotSurvey = function(survey) {
      // show survey to the visitor

      // collect answers
      var answers = [
        {question_id: 54545211, response: 'Yes'},
        {question_id: 54545212, response: 2},
        {question_id: 54545213, response: 2341},
        {question_id: 54545214, response: 'Awesome'},
      ]

      survey.respond(answers)
        .then(function() { alert('Answers sent') }
        .catch(function(error) { alert('Error') };
      };

    engagement.getSurvey().then(gotSurvey);
  });
});

Parameters:

  • answers ( Array ) An array with answers. Every answer is an Object containing question ID and response.

Returns:

  • ( Promise ) — Fulfilled with an empty object when successful or rejected with an Error

    Quickly fuzzy find classes, mixins, methods, file:

    Control the navigation frame:

    You can focus and blur the search input: