SurveyGizmo's CustomScript Action now supports the LUA programming language.
Legacy Custom Scripting Language Deprecation Plans
New accounts (created after October 29, 2018) will only have the option to use Lua in scripts.
As of October 29, 2018 Custom Scripting Actions will default to Lua as the scripting type in the Custom Scripting Action for accounts created before this date. You will be able to switch to the Legacy Custom Scripting; though we highly encourage using Lua.
In the long term, Legacy Custom Scripting Actions will be switched to read-only. Read-only scripts will continue to function; you will just be prevented from editing. The exact date on this is to be determined; we will send notifications well ahead of time.
While SurveyGizmo is one of the most flexible survey tools around, we get requests for customizations that are not available out of the box. This is where JavaScript and Custom Scripting can save the day. If you have scripting chops you can use the JavaScript action or the Custom Scripting action to achieve the survey of your dreams.
Randomization is a very popular survey tool for eliminating bias introduced by order and/or survey fatigue. Within Alchemer 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.
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 and Setup
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. This is highlighted in the script below.
--[[********* Record Presentation 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
else
PO = PO ..",".. ThisPage
end
-- remove leading comma if present
offset = 0
len = 1
if (substr(PO,offset,len) == ",") then
PO = substr(PO,1)
end
--save PO
setvalue(POqid,PO)
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.
POqid - This variable will indicate the question ID of the textbox question that stores the random order.
Hide the Random Order Textbox - Once you have confirmed your script is working you can hide this field from respondents' view. To do so, edit the question, go to the Logic tab and select the option to Hide by Default. You're all set!