Have Questions? (800) 609-6480

Pushing Values into the Survey through the Query String: Part 1


Whether it is referred to as query strings, token variables, GET string variable, or URL variables, it all means the same thing: The ability to 'push' information into the survey through a weblink (in this case a survey link!). The act of sending this information into the survey through the survey link is called passing.

Basic Query String Construction

Caution: Constructing your survey link with a query string must be done separately from the Distribute tab within SurveyGizmo. The link with the query string should be used for sending emails through your own mail service or when placing the links on particular websites or sources. Do not place query string values within the custom link areas of the Distribute tab.

Take the following imaginary survey link:

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

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

?variable=value

This would make your survey link as follows:

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

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

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

You have probably noticed a few symbols are being used as part of the query string. They are identified in blue in the examples and represent the syntax of a query string. Let's explain these quickly.

  • ? - (Question Mark) This identifies the beginning of the query string and must be placed between the link and the contents of the query string.
  • & - (Ampersand) This is used to add additional variable/value data in the query string and is used before each addition variable/value pair.
  • = - (Equals, not in blue) This separates the variable from the value assigned to that variable

Now that the structure is clear, it's time to learn about the restrictions within SurveyGizmo for using the query string.

Restrictions Within SurveyGizmo

There are a few key rules regarding the query string:

  • Do not use the variable names id, sguid, or survey, these are reserved
  • Do not use any symbols or numbers in the variable name, letters only
  • Do not use capital letters as URL variables as our system will not be able to capture them
  • Spaces are not allowed in the variable name and should be replaced with %20 if in the value field (e.g. ?name=John%20Smith ) To learn more about percent encoding, check out Percent Encoding Wiki
  • If the value contains symbols, the query string should be created by URL encoding the value. This can be done in many programming languages easily, such as with PHP and ASP.

The following are examples of invalid query strings (do NOT do these):

  • ?user_id=123
  • ?id=6323
  • ?survey=8423
  • ?1name=Bob
  • ?name=Bob Edward Jr.

Viewing the Submitted Variables within SurveyGizmo

SurveyGizmo captures all variables (excluding the restricted ones mentioned above) as part of that particular response.

Viewing URL Variables in Individual Responses:

If you'd like to view your URL variable for all of the responses in your survey at once without any extra survey design, we recommend running a CSV/EXPORT of your survey data.

Step 1: Go to Project--> View Data tab

Step 2: Choose the response you'd like to view 

Step 3: Click on the Details tab once you're inside

URL_Variable.png

Next to "URL VARIABLE" you will see the variable defined and then the data that was passed through.

This will display any variables and their values captured from the query string. If a respondent were to use the following link our individual response would capture the URL variable as pictured above:

http://www.surveygizmo.com/s3/12345/my-survey?uid=123

SPECIAL NOTE: If you have multiple unique URL Variables they will be listed one after another on this page

 

Viewing URL Variables for All Responses

If you'd like to view your URL variable for all of the responses in your survey at once without any extra survey design, we recommend running a CSV/EXPORT of your survey data.

PushingValuesPt1-1.png

Step 1: Go to Project-->Export Data

Step 2: Click CSV/EXCEL (not the quick version)

Step 3: Check off "Include URL Variables" and then click "Create Export"

Step 4: Go to the Run Export and click "Run Export Now"

Step 5: Click "Download Export"

export_4.png

The column header will include 'URL Variable:' and then whatever variable was passed through the query string. Each row in that column will then display the individual respondents URL variables. If you have multiple URL variables, each unique variable will get it's own column.


In Part 2: Query String Integrations of this series, methods for using the query string value within your survey are explored. Part 3: Query String Examples   follows with specific use cases and examples of using query strings in a real world example.

Have questions? Want to comment on this? Join the discussion on our SurveyGizmo Support site.

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

Best of SurveyGizmo Weekly

By . In Know How.

Likert Scale – What is it? When to Use it? How to Analyze it?

April 24 2012 -

In all likelihood, you have used a Likert scale (or something you’ve called a Likert scale) in a survey before. It might surprise you to learn that Likert scales are a very specific format and what you have been calling Likert may not be. Not to worry — researchers that have been doing surveys for… Read More »

By . In Interviews.

How One Company Beat All Odds in Conducting An Offline Survey In Africa

World-Wize Surveys used the SurveyGizmo API to build their own iPad survey app. Want to know how? Read on.

By . In Best Practices.

How to Get A Raise By Creating Surveys You Can Act On

The most successful survey creators know that creating a survey starts with a solid plan, before you even begin building your survey.

More from our Survey Experts