A twist on “show a number of randomly selected pages from a survey”

0

I am trying to set up a survey to randomly present 3 of 5 concept statements to respondents, each on a separate page with a set of common questions.  It’s easy enough to do this with the custom script to randomly select a subset of pages: https://script.surveygizmo.com/help/show-a-number-of-randomly-selected-pages-from-a-survey

However, I also need to exclude some of the respondents from seeing some concepts that aren’t relevant to them.  I have 3 segments of respondents; Segment A qualifies to see all 5 concepts, and I will use the script referenced above to randomly select just 3 to show them. Segment B is qualified to see concepts 1-3 only.  Segment C is qualified to see concepts 3-5 only. For Segments B and C, I need to show all three of the relevant concepts to them, in a random order.

There must be some logic I can set up in the custom script for this but I’m not much of a coder and haven’t been able to find any examples like this on the support pages. Any advice would be appreciated!

Jim Wetherill answered
    0

    Hi Glenn,

    That simplifies things.  Instead of using the sgapiURLValue to get the URL variable, you can use the sgapiGetValue function to return the answer to your screener question.  You can then use that to trigger the proper IF statement.

    %%xsegment = sgapiGetValue(the screener question ID);
    IF %%xsegment == “a” {}
    IF %%xsegment == “b” {}
    IF %%xsegment == “c” {}

    glennwestlake378267 commented
      • Hi Jim – I really appreciate your help…but I’m stuck again. I’m using a multiple-answer checkbox for creating the segments, and the segments are created through different combinations of answers. I was thinking the “sgapiIn_Array” function could be used to create the segments but I haven’t had any luck with it so far.

      0

      Hi Glenn,

      The sgapiGetValue function can also be used to return the responses to a checkbox type question.  Once again, I have no personal expereince in using this function to return the responses from a multi-answer question, but there is an example survey on the documentation page for sgapiGetValue that may be useful.

      When I have been forced to learn coding, I have found it useful to build a separate test survey with just the relevant questions.  I have also found that the best approach is to write the script in small chunks.  When you get one chunk running correctly, then you extend and build the next chunk.  Use the %%output .= code that appears in the documentation to check what the sgapiGetValue function is returning.  

      I am sorry that I can’t be of more assistance.  I can tell you that once you have spent the time to complete your first coding project, it opens your thinking to new possibilities.

      Depending on your budget and frustration level, you can always pay SurveyGizmo to write the script for you.

      glennwestlake378267 commented
        0

        I have no personal experience in setting up this kind of scenario.  However, if I was asked to do this  the first thing I that I would try would be to assign a URL variable for each of the three respondent segments, and then use a sgapiURLValue function in the script to return the variable’s value.  I would then use a series of IF statements to run the proper page hiding script.

        In pseudo-code it would look something like this:

        %%xsegment = sgapiURLValue(“segment”);
        IF %%xsegment == “a” {}
        IF %%xsegment == “b” {}
        IF %%xsegment == “c” {}

        This assumes that you will be able to send unique survey URLs to each of the three segments.

        Good luck

         

        glennwestlake378267 commented
          • Hi Jim – Thanks for the advice. Unfortunately, my segments will be defined by how respondents answer one of my screener questions. Any ideas for this situation? Thanks!
            Glenn

          ×

          Login

          Question stats

          • Active
          • Views2262 times
          • Answers3 answers
          • Followers1 follower