Additional scripting solutions will be added in the future. Please reach out to Alchemer with comments and suggestions on solutions you'd like to see via the link here.
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 Alchemer 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!
Show a limited number of random pages (or questions). Use a quota-based Least Fill strategy to ensure pages (or questions) are presented as evenly as possible.
If you are not using the options below it will be easier to use the Basic Solution.
If you have a license that provides Lua script and will be limiting with 10 or fewer Checkbox options and collecting 1,000 or fewer responses, it will be easier to use the Least Fill (Query) Solution (link coming soon).
Limit based on selections made in a Checkbox question Option Show a limited number of random follow up pages (or questions) based on selections made in a Checkbox question (which could be a list of Concepts or Brands). A Prioritization Option ensures the respondent will always be asked about a specific selection if checked (for example: the Brand you're researching).
Respondent Condition Option Ensure pages (or questions) are presented evenly to respondents who fall into one or more Conditions (such as Gender, Race, or Age Bracket). Note that this is limited as Conditions can quickly generate a large number of Quotas.
See also: Show Random Pages or Questions
Effort: ✔ ✔ ✔ (mostly adding quotas and page logic)
This solution fills a Hidden Value Action with a list of random name you define using quotas. Later pages or questions use this list to determine if they should be shown or hidden based on whether it contains a specific name or not.
Step 1: Add Two Hidden Value Actions
(1) Add a new page.
(2) Add a Hidden Value Action with the title random-pages-to-show. The script will set this to a list of randomly selected quota names.
(3) Add a second Hidden Value Action with the title quotas. The script will set this to the quota counts that were found at the time this respondent was taking the survey. This is useful if you want to understand why a response was presented specific pages.
Step 2: Add Quotas
If one is using the Respondent Condition Option skip this step and see directions for this option at the end of the article.
The example below use the names A, B, C, D. If one is using other names, ensure they are short single words that are not a substring of one another (ie: "SPS" and "XSPS" aren't allowed).
The Quotas must follow the naming convention of fill-Name (ie, they must start with "fill-"). Set each quota to check if random-pages-to-show "contains" the Name. And set each quota to Continue collecting responses on the Complete Actions tab.
Step 3: Add a Webhook Action to get the quotas
Add a Webhook Action to the top of the page added in Step 1 to get the quotas:
1. Choose GET Method
2. Enter the URL below for your data center (US, CA, or EU), updating the highlighted sections with the survey ID and API Token/Secret
US - https://api.alchemer.com/v5/survey/1234567/quotas?api_token=***&api_token_secret=***
CA - https://api.alchemer-ca.com/v5/survey/1234567/quotas?api_token=***&api_token_secret=***
EU - https://api.alchemer.eu/v5/survey/1234567/quotas?api_token=***&api_token_secret=***
3. Choose Display it at the bottom of page for what to do with the returned data.
- Set the highlighted values
Step 5: Add random pages (or questions)
Add the pages (or questions) to be randomly shown.
Set the Display Logic for each to only show if the random-pages-to-show Hidden Value Action added in Step 1 contains one of the quota Names. The text must match exactly, including case.
Step 6: Test
The example below chooses two of four brands and runs a Least Fill separately for Male and Female respondents.
However, because Concept B has an asterisk in the Aware of Reporting Value, it is Prioritized. To prioritize within a Least Fill, the code sets the Brand response count to -1, ensuring it moves to the start of the Least Fill list. The remaining Concepts are randomly chosen based on the lowest response counts. In the above example, this results in brand B and D being selected.
Step 6: Hide the page from Step 1
When testing is complete hide the page added in Step 1:
- Enter sg-hide for the page's Layout tab > CSS Class Name. This class will hide the page.
Limit based on selections made in a Checkbox question Option (otherwise skip this step)
- Add a Brand Awareness Checkbox Question to the survey with an option for each Brand.
- The Reporting Values must match the names used for the Quotas later. Set Reporting Values to Custom and edit them to ensure they are short, single words and that none is a substring of another (ie: "SPS" and "XSPS" aren't allowed). Pro tip: simply set the Reporting Values to letters of the alphabet.
- Prioritization Option: Add an asterisk at the end of the Reporting Values (ex: B* below) to ensure the Brand is always presented if the respondent is aware of it.
Respondent Condition Option (otherwise skip this step)
- Add one or more Radio Button questions, like Gender.
- Set the Reporting Values to Custom and edit them to to be short single words .
Create a Quota for each Name / Concept combination. Each quota checks one Condition and Name to see if it's contained in the random-pages-to-show added in Step 1. The Quotas follow the naming format of fill-Condition-Name. If one is using two conditions, use the form fill-Condition1-Condition2-Name.
For example: the Quota fill-Male-Black-A would need the CONDITIONS array to have the Gender merge code first and the Race merge code second:
CONDITIONS = [ `[question("value"), id="2"]`, // gender question merge code `[question("value"), id="3"]`, // race question merge code ]