Show a Number of Randomly Selected Pages from a Survey

As part of our core randomization options, you have the ability to display x number of random questions on the page. Unfortunately, there is not a built-in way to do the same with pages in a survey. Never fear!  Fortunately, it's pretty easy to script. We'll cover the steps to use a pretty simple script to accomplish just this. These steps assume a basic familiarity with SurveyGizmo and programming.

See this script in action in an example survey. 

OR

Add a survey with this setup to your account!

Features and functions used in this script:

The Script and Setup

Set up your survey pages as you wish. This script supports static pages throughout the pages that are being randomized.

For our example, we're conducting a community services survey. The survey has an initial page where we collect demographic information from the respondent and a thank you page. These pages will always display to each survey respondent.

Following the initial page, there are four pages where we collect information about the following four community services:

  • waste collection (page ID 3)
  • the recycling program (page ID 4)
  • city parks (page ID 5)
  • dog parks (page ID 6)

In the interest of reducing respondent fatigue and survey abandonment and ultimately getting better data, we only want to burden each respondent with responding to two of the four community services pages.

To set this up we added a custom script action to the initial page (which everyone will see) and pasted the below script. 

--Pages to be randomly hidden go here. Make sure they are comma separated, no spaces.
pagesHideRan = {3,7,5,6} 
--Amount of pages you want shown from the list above. No quotes or commas are needed.
shown = 2

--Do not change after this line.
shuffled = tableshuffle(pagesHideRan)
for key,page in pairs(shuffled) do

	hidepage(page,true)
end

for i=1, shown do

hidepage(shuffled[i],false)

end

Required Customizations

In the script above you will need to customize variables highlighted in yellow in order to make the script work in your survey.

pagesHideRan - PageIDs of the pages you wish to be randomized. Not sure where to get your IDs?

shown - Number of random pages you wish to show.   

Scripting and Other Custom Solutions

We’re always happy to help you debug any documented script that is used as is. That said, we do not have the resources to write scripts on demand or to debug a customized script.

If you have customization ideas that you haven't figured out how to tackle, we're happy to be a sounding board for SurveyGizmo features and functionality ideas that might meet your needs. Beyond this, check out our Professional Services; these folks have the scripting chops to help you to achieve what you are looking for!

Basic Standard Market Research HR Professional Full Access Reporting
Free Individual Team & Enterprise
Feature Included In