Record Page Title of Randomized Pages

Randomization is a very popular survey tool for eliminating bias introduced by order and/or survey fatigue. Within SurveyGizmo you can randomize questions, pages (or pages in groups) or even answer options! We have a merge code [page("pagepath")] that you can use in a hidden value to store the page SKUs of each page that your survey respondent sees, however, some customers who have custom page titles would prefer to store the page title. In this example, we cover a script for recording the page titles in order that they were displayed for each response when using page randomization.

Check it out in an example survey!


Add a survey with this setup to your account!

Functions used in this example:

Set up your survey pages as you wish. 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.

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 order bias, we will randomize each of the community services pages.

The Script

To start you'll need to create a Textbox question to store the random order. For our example, we put this on a new page so that we can display the stored value. You can do the same for testing. Then just move it to another page in your survey and select the option to Hide By Default on the Logic tab once you've confirmed it is working properly.

Next, at the top of each page in your survey create a custom script action and paste the below code. The only change you'll need to make is the question ID for your textbox question that you created to store random order (POqid variable).

********* Record Presention Order of Randomized Pages ********
This script goes at the top of each Randomized Page.
Presentation order is saved as a comma delimited list
in a hidden text question at qid 58.

-- get current page Title
ThisPage = currentpagetitle()

-- add ThisPage to end of PO (Presentation Order)

-- get Existing PO list from POqid
POqid = 58
PO = getvalue(POqid)

-- append ThisPage to end of PO list
if (PO == nil) then
	PO = ",".. ThisPage
	PO = PO ..",".. ThisPage

-- remove leading comma if present
offset = 0
len = 1
if (substr(PO,offset,len) == ",") then
PO = substr(PO,1)

--save PO

Required Customizations

POqid - This variable will indicate the question ID of the textbox question that stores the random order.  

Now you're ready to test. Record several responses and verify that the randomization order is storing properly.

Hide the Random Order Textbox

Now we just need to hide this field from respondents' view and you're all set! To do so, edit the question, go to the Logic tab and select the option to Hide by Default. You're all set!

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