sgapiAddContactToInvite(%%linkID, %%email, %%fields, %%customfields, %dupsok)

Important Update to Custom Scripting

SurveyGizmo's CustomScript Action now supports the LUA programming language. Visit our NEW Lua Scripting Resources!

Legacy Custom Scripting Language Deprecation Plans 

  1. New accounts (created after October 29, 2018) will only have the option to use Lua in scripts.
  2. 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.
  3. In the long term, Legacy Custom Scripting Actions will be switched to read-only. The exact date on this is to be determined; we will send notifications well ahead of time.

This function adds a contact with the list of given fields to the given invite.

  • %%linkID* is the Invite ID of your email campaign
  • %%email* is the email address of the contact you'd like to add
  • %%fields is an array of the contact fields you'd like to update
  • %%customfields is an array of the custom invite fields you'd like to update
  • %%dupsok allows duplicate email addresses to be added to the invite (defaults to 'false' if not included). Note that you should use a string interpretation of the boolean. 'False' will work but false will not.
%%field or %%customfield parameter Invite Contact Field
sFirstName First Name
sLastName Last Name
sOrganization Organization
sDivision Division
sDepartment Department
sTeam Team
sGroup Group
sRole Role
sHomePhone Phone (Home)
sFaxPhone Phone (Fax)
sBusinessPhone Phone (Work)
sMailingAddress Address
sMailingAddress2 Suite/Apt
sMailingAddressCity City
sMailingAddressState Region
sMailingAddressPostal Postal Code
sMailingAddressCountry Country
sTitle Job Title
sURL Website
sCustom1-10 Invite Custom Field 1-10

Parameters are case sensitive and are defined as an array where the key is the field name.


This function is great if you're collecting contact information in one survey, but want to set up an email campaign with that new contact information in another. It allows you to gather all your information and automatically set up a follow up survey email campaign, so you could easily send follow up surveys!

In this example we'll add a contact to the email campaign with ID 123456. linkID is the inviteID and can be found in your email campaign. The contact information will come from fields in the survey.Question IDs 2-5 will contain the email address, first name, last name, and organization respectively.

%%linkID = 123456;
%%emailaddress = sgapiGetValue(2);
%%field = array();
%%field['sFirstName'] = sgapiGetValue(3);
%%field['sLastName'] = sgapiGetValue(4);
%%field['sOrganization'] = sgapiGetValue(5);

sgapiAddContactToInvite(%%linkID, %%emailaddress, %%field);