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.
Some merge codes support a default attribute that allows you to set a default value to display when the merge code is empty.
The following merge codes support the built-in default attribute.
[question("value"), id="3"]
[question("option title"), id="2"]
This JavaScript allows you to specify a default value for an empty merge codes that do not support the default attribute. This comes in handy if you are using URL Variables merge codes or an Email Campaign merge code to pre-populate a survey.
Add a survey with this script and setup to your account.
The Setup and Script
Add the merge code for which you wish to specify a default value. This can be text in a Text/Instruction element or question text.
On the editor toolbar, click the More ellipsis and then the Source button.
Wrap your merge code in the following HTML:
<span id="mergeCode">[merge("code")]</span>
So for our example, we are using JavaScript to populate the merge code for the URL Variable merge code for first name: [url("firstname")].
Note, if you plan to use this JavaScript for multiple merge codes on the same page the ids will need to be unique, e.g. mergeCode, mergeCode2.
So our resulting HTML will look like so:
<span id="mergeCode">[url("firstname")]</span>
Now copy and paste the below JavaScript in a JavaScript Action and make the required customizations.
$(function() {
var mergeCode = '[url("firstname")]';
if (mergeCode == "") {
document.getElementById('mergeCode').innerHTML = 'Valued Customer';
}
});
Required Customizations
Merge Code - The merge code in this example is [url("firstname")]. Change to the merge code you are using.
Default Text - In this example the default text is "Valued Customer." Change this text to what you would like to display when your merge code is empty.