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:

http://www.surveygizmo.com/s3/1234567/my-survey

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

?variable=value

Your survey link would look as follows:

http://www.surveygizmo.com/s3/1234567/my-survey?variable=value

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:

http://www.surveygizmo.com/s3/1234567/my-survey?userid=121&name=bob

Operators

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

  • ?  - The question mark identifies the beginning of the query string and must be placed at the end of the link, before 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 Webhook 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 detected. 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.

http://www.surveygizmo.com/s3/1891084/Holiday-Party-Invite?store=boulder

URL Variables in Response Details

Setup a Hidden Value

You can use Hidden Values to rename a URL variable for reporting purposes (e.g., a=32 becomes age=32).

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

  1. Click the Add New 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 Hidden Values in your survey. For example, if you plan on capturing respondents' first names, calling it First Name will be helpful later when you need to use it for pre-population or reporting purposes.
  3. Click the Select a Merge Code link below the Populate with the following field.

    1. Search for "url variable" in the available search field
    2. The URL Variable merge code will return in the search results; click Insert; the merge code will be inserted into the Populate with the following field:
      Populate Hidden Value with URL Merge Code
    3. You will want to modify this default code by deleting the triple x and entering the name of 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.
      Customized URL Merge Code
  4. When you are finished customizing 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 have 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 under the First Party Data category.

URL Variable as Logic Source

  1. To set up logic using a URL variable, start by selecting URL Variable from the First Party Data options in the left-most column.
  2. In the text field that appears to the right, enter your URL variable name.
  3. Next, choose an operator and 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: Example Logic Condition

URL Variable Reporting

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

Learn more about this reporting element by visiting the expanded documentation.

URL Variables in Standard Reports

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.

URL Variables in Legacy Summary Reports

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.

  1. To do so, create either a Radio Button or Checkbox question. Choose a Radio Button question 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.
  2. 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.
    Reporting Values Should Match URL Variables
  3. On the Layout tab of the question in the Default Answer field click the Select a Merge Code below the field.
    Default Answer Merge Code Link
  4. Search for url variable within the provided search field and once URL Variable is returned, click the Insert option to insert it into the default answer field.
    URL Merge Code in Default Answer
  5. Change the xxx to your url variable name and click Save Question.
    Default Answer Customized URL Merge Code
  6. By default this question will display 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.
    CSS Class Name
  7. When you run a Standard Report you can now report on the question that is storing your URL Variable.
    Report on URL Variable Default Answers

Adding URL Variables to Survey Links

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

  1. 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.
    Edit or Create New Link
  2. To add a URL variable to each link, go to the Advanced tab of the link editor. In the URL Variables field you will enter a variable and value pair like so: variable=value.

    For example let's say we are creating links for each store and manager. We will start by specifying a variable called store  and 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 will 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!
    Add URL Variables to Link
  3. Save your link and test as needed! URL Variables added to your links will be hidden from view (for respondents) when the link is shared. 

Add URL Variables to an Email Campaign

You can also use these variables in an Email Campaign.

  1. Click the Share tab and select your campaign or make a new one.
    Edit or Create New Email Campaign
  2. Once you have accessed the campaign, click the Settings tab and input your variables in the URL Variable field. The URL Variables field is located near the bottom of the Advanced Settings page.
    Add URL Variables to Email Campaign
  3. Make sure to Save Campaign Settings when you are finished.


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