Using URL Variables to Pass Data

URL Variables make for a quick method for pre-populating existing data into a survey. With a simple query added to the end of the survey link, data can be stored as part of each survey response. This gives you the ability to push information into the survey through your survey link to store for use within the survey and/or to use when reporting on the survey response.

You can use URL variables to...

  • integrate with panel companies or other third parties (pass unqiue IDs into and out of the survey, along with response statuses such as terminate, overquota, and complete).
  • prepopulate data in the survey that is either visible or invisible to the survey respondent (pass the name of a customer service representative or a ticket number into a survey).
  • drive survey logic (show or hide pages and questions based on different variables).
  • pass information between surveys (pass a unique identifier in order to connect responses to individuals across surveys).
  • perform a unique function (only allow one response per value, go to the beginning of a response, or go to a specific page).

Constructing URL Variables

Take the following example survey link:

If you wanted to pass a variable with the value equal to the word 'value,' you can add the following to the survey link:


Your survey link would look as follows:

If you wanted to add a variable named 'userid' with a value of '121,' and also include a variable 'name' with a value of 'Bob' your link would be constructed as follows:


The question mark, ampersand and equals sign are operators used in the syntax of query strings.

  • ?  - The questions mark identifies the beginning of the query string and must be placed between the link and the contents of the query string.
  • & - The ampersand is used before each subsequent variable/value pair in the query string.
  • - The equals sign separates the variable from the value assigned to that variable

 Best Practice Tip

When constructing URL Variables to use in surveys, we recommend using all lowercase letters for the variable name. This will give you the most reliable results for using URL Variables within surveys, as well as passing them out of surveys using actions like the HTTP Connect and URL Redirect.

If you need to pass special characters via a URL variable, you may need to encode the special characters. Learn more about URL encoding.

Storing URL Variables for Later Use

URL variables are stored by default whenever they are present. To confirm, click on a response on your Responses tab and go to the Details tab. Any URL variables that were present in the link for this response will be present. As you can see from the screen capture below this survey link was sent out with the below query that was then automatically stored.

Setup a Hidden Value

You can use hidden values to rename a URL variable for reporting purposes (a=32 becomes age=32).

When you are you are using Hidden Values to capture URL variables, you'll want to add these to the first page of the survey.

1. Click the Action link on the first page of the survey.

2. Select Hidden Value from the list and Enter a title for your Hidden Value. A good title is important, especially if you plan on including several of Hidden Values in your survey. For example, if you plan on capturing respondents' first name, calling it First Name will be helpful later when you need to use it for pre-population or reporting purposes.

3. Click Save Action and Edit.

4. Click the Insert merge code link to the lower right of the Populate with the following field. In the dropdown menu select from URL Variable from the Advanced portion of the list and click the Insert button.

This will insert a template merge code like so:

You'll want to modify this by deleting the triple x and entering your URL variable. The below merge code example would pull the value of the store variable from this query string: ?store=val

Sample Merge Code: [url("store")]

If the query string variable was STORE, the above merge could would still work properly as it ignores the case of the query string variable.

5. When you are finished customize the merge code, click Save Action.

Using URL Variables in Your Surveys

There are so many things you can do with URL variables in surveys it's nearly impossible to list them out. We've found that the best way to learn about URL variables is to see them in action; head over to our Using URL Variables in Your Surveys Tutorial to learn more!

Using URL Variables in Survey Logic

URL variables are available to in the logic builder throughout your survey.

To set up logic using a URL variable start by selecting URL Variable from the Advanced options in the left-most column. In the text field that appears to the right enter your URL variable name. Next choose an operator and the enter a value to complete the logic rule.

This is one place where having stored the URL variable in a hidden value makes your life a little easier as you will not have to key the variable name when setting up logic.

URL Variable Reporting

In Standard Reports, URL Varibles can be added as a report element via the Insert Tool by selecting the URL and Hidden Values option. The URL Varible reporting element will display as a pie chart with a corresponding table.

In Legacy Summary Reports, URL Variables will report as an appendix element which is just a list of all possible values and the frequency for which each value was recorded.

If you have a set list of values that you plan to store in a URL variable you may want to report on this as a pie chart or bar chart for a more visual representation. You'll need to set this up in advance of collecting data.

To do so, create either a Radio Button or Checkbox question. Choose a Radio Button quesiton if you wish to create a Pie Chart in your Reports and Checkbox question if you wish to create a Bar Chart in your reports.

Add all possible URL variable values as options in your question. Make sure that the reporting values match exactly, including case, with the values that will be sent to your survey via the URL.

On the Layout tab of the question in the Default Answer field click the Insert Merge Code link in the lower right.

Select URL Variable from the Advanced portion of the dropdown list and click the Insert button.

Change the xxx to your url variable name and click Save Question.

By default this question will display by default to your survey respondents. If you wish to hide it, enter sg-hide in the CSS Class Name field just below the Default Answer field.

When you run a summary report you can now report on the question that is storing your URL Variable with either a Pie Chart or Bar Chart.

Adding URL Variables to Survey Links

Now that you've learned how to construct URL variables, it's time to add them to your survey links!

Go to the Share tab and click on a survey link from the Email Campaigns and Source Tracking list. If you want to create a new link for this URL variable, you can do so by clicking Create A New Tracking Link.

To add a URL variable to each link, go to the Advanced tab of the link editor. In the URL Variables field you'll enter a variable and value pair like so: variable=value.

For example let's say we're creating links for each store and manager. We'll start by specifying a variable called store then add an equal sign (=) and the store value this link represents. We can add a second variable by adding an ampersand (&) and then specifying another variable and value pair. Then, we'll repeat these steps for each tracking link we create.

Please note that you do not need to add the question mark at the beginning of the string, it's already built-in!

Save your link and test as needed! URL Variables added to your links will be hidden from view when the link is shared. 

Add URL Variables to an Email Campaign

You can also use these variables in an Email Campaign by clicking the Share tab and select your campaign or make a new one. Once you're in the campaign, click the Settings tab and put your variables in the URL Variable field.

Basic Standard Market Research HR Professional Full Access Reporting
Free Individual Team & Enterprise
Feature Included In