More Topics

Passing Data In

You can pass data into the forms to be stored with the response data using either the Embed JavaScript API or querystring parameters. Note that you will need some basic technical knowledge to use the querystring parameters or an understanding of JavaScript to use the JS API.

Step One: Defining your data

Before you can import the data into the survey, the field names must be defined in the survey builder using the “Hidden Fields” element. Simply list out the names of your fields, all data passed will be stored as a string. Field names must contain no spaces and only “-“ or “_” as special characters. This stage is necessary for both the QueryString and API methods.

Step Two: Passing the data in

Method one – QueryString parameters

Use this method when calling the survey directly from your website using a hyperlink. Typically for the data to be unique to each participant using the link you would generate link server side. Below is how a normal survey link looks without the parameters. Use the URL of the survey you have created, this is found on the launch page under “Link to your survey”.

Each of your parameter names need to be prefixed with “custom_”, note that they should not be defined using this prefix in the builder.

Example URL with custom fields:

Using this URL, the data passed in the QueryString should be being saved in your responses on submission of the form.

Method two – JavaScript Embed API

You can also import data using the embed API, use this when you want the survey to be included into your website. Note that you will need a good knowledge of JavaScript to use this.

Read the basics of the api here

Simply add a property called “custom” to the config object, this may contain a single level object of strings. Example Below.

	formId: "####",
	custom: {
		userId: "32453",	
		firstName: "Luke",
		lastName: "Smith",
		email: ""

Step Three: Using the data in the live survey (optional)

As well as storing the data passed, you can display it to your participants in the text of the survey, including questions and answer options, using the Text Piping feature. Read the documentation to find out more.

Step Four: Passing the data out in a redirect URL (optional)

It may be necessary to pass some of the data back to your website so you can have confirmation that your user has completed the response. For this example we’re going to use the email address as the user id. You could pass a unique code.

From the build page, select the “Thank You” page of your survey. In the sidebar choose “Redirect to web address” you will be presented with a field where your web address should be entered. Below is an example of how you can output the code to your website using GET parameters.[custom_email]

The part of the address [custom_email] will be replaced with the input email address in the querystring parameters (or API call) you passed earlier.