Have Questions? (800) 477-0970

Scripting Sample: Automatic Survey Login Action


Please Note:This is a tutorial for SurveyGizmo 2.0 users. We will be updating this for SurveyGizmo 3.0 users ASAP

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

Have you tried SurveyGizmo yet? Try our 14 day free trial

The Survey Expert Blog

By

Why Survey Design Matters for Feedback Surveys

February 3 2012 -

Survey Expert Ryan Farmer observes that many well-known companies aren’t branding their surveys, and discusses why survey design is hyper-important when you want to gather customer feedback.

By

New Team Management & User Permissions System

Starting February 2nd, SurveyGizmo is launching a new set of user management features. Learn more about them here!

By

5 Questions with SurveyGizmo co-founder and CEO Christian Vanek

Boulder’s Daily Camera newspaper interviews Christian Vanek, who shares what’s next for the company.

More from our Survey Experts