Online Survey Tutorials
SurveyGizmo Tutorials and Help Documentation
Tutorial: Scripting Sample: Automatic Survey Login Action
This series is dedicated to showing advanced functionality within SurveyGizmo using the Custom Scripting action (Pro plan or higher). While the tutorials are meant to be portable and easy to insert into your own survey, it will be necessary to understand advanced concepts such as Question IDs. These scripts are provided as-is without additional support for alterations.
This script uses the following question types or actions:
- Survey Login action
- Hidden Value action
Description
If passing the password for a Survey Login action through either the query string or an Email Invitation Contact Field, the Default Value for the Survey Login action can be automatically set when you edit the Survey Login action. This script will go a step further and ‘click’ the Next Page button for the user after 0.5 seconds. It also includes a check to ensure that it only ‘clicks’ if this is the first time the page has loaded (in case the Default Value is not valid).
The Script
%%counterqid = 130; // Hidden Value field's Question ID %%loginqid = 128; // Survey Login action's Question ID /**** DO NOT ALTER BELOW THIS POINT ****/ if (sgapiGetValue(%%counterqid) == ''){ sgapiSetValue(%%counterqid,1); %%output .= "<script type='text/javascript'>setTimeout(function (){document.getElementById('sg_NextButton').click();},500);</script>"; }
The Steps
- Add Action > Custom Scripting Control and paste in the above code
- Add Action > Survey Login and make sure to set the Default Value field correctly using the appropriate merge code
- Add Action > Hidden Value and save it without setting any value (leaving it blank)
- Collect the Question IDs for the Hidden Value field and the Survey Login action and input their numbers in the appropriate place within the Custom Script (130 and 128, respectively, in the script)
- Save all changes and test in preview (adding a query string value) or with an email invitation, depending on your method of setting the Default Value. If using an email invitation, do not use the ‘Test’ email invitation link, but send a real invitation to test the functionality.
Warnings
This script will function properly on all modern browsers and may not work on browsers older than:
- Internet Explorer 6+
- Firefox 2+
- Chrome
- Safari

