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 unique IDs into and out of the survey, along with response statuses such as terminate, over quota, and complete).
- The word "source" when used as a URL variable is not compatible with quotas in surveys. We suggest avoiding using the word source when creating survey quotas.
- pre-populate 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.
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.
- Click the Add New Action link on the first page of the survey.
- 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.
- Click the Select a Merge Code link below the Populate with the following field.
- Search for "URL variable" in the available search field
- 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:
- Modify this default code by deleting the three x's 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 code would still work properly as it ignores the case of the query string variable.
- 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.
- To set up logic using a URL variable, start by selecting URL Variable from the First Party Data 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 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.
The word "source" when used as a URL variable is not compatible with logic in surveys. We suggest avoiding using the word source when driving logic conditions.
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!
- 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 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! - 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.
- Click the Share tab and select your campaign or make a new one.
- 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.
- Make sure to Save Campaign Settings when you are finished.
URL Variable Reporting
In Standard Reports, URL Variables 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 Exports
Upon creation of a CSV/Excel Export select the option to Include URL Variables in order to include this data in your export. If you forgot to select this option when creating the report, it is also available under Customize Report > Settings.
Admin
— Bri Hillmer on 10/01/2018
@Sarah: You'll need at least the Professional/Adventurer license level in order to set up the Pre and Post Test survey as described here: https://help.surveygizmo.com/help/pre-post-test-survey
I hope this helps!
Bri Hillmer
Documentation Coordinator
SurveyGizmo Customer Experience Team
Admin
— Bri Hillmer on 10/01/2018
@Kayleen: You sure can! Check out our tutorial that covers passing values from a URL Redirect for more info:
https://help.surveygizmo.com/help/url-redirect-send-values
I hope this helps!
Bri Hillmer
Documentation Coordinator
SurveyGizmo Customer Experience Team
— Tom on 09/29/2018
Can I pass survey data from one survey gizmo survey to another via a URL variable redirect at the end of my survey?
— Sarah on 09/28/2018
What plan do I need to do this? https://help.surveygizmo.com/help/url-redirect-send-values (Gateway survey and pre-post survey like this http://www.surveygizmo.com/s3/2110997/Pre-Test-and-Post-Test-Survey)
Admin
— Dave Domagalski on 01/25/2017
@Martina: Thank you for your question!
I have just updated the feature/license grid at the bottom of this article to provide information on which license types are needed to have access to the features described.
I hope this gives you the information that you are looking for!
Cheers,
David
Documentation Specialist/Survey Explorer
SurveyGizmo Customer Experience
— Maciej on 01/25/2017
In what plan is this available? Does Standard Plan include this?
Admin
— Bri Hillmer on 09/14/2016
@Tech-billing: SurveyGizmo will capture any URL variable that you choose to pass. For example:
https://www.surveygizmo.com/s3/1234567/survey?utm_source=email&utm_medium=newsletter&utm_campaign=spotlight&utm_campaign=etc
I hope this helps!
Bri
Documentation Coordinator/Survey Sorceress
SurveyGizmo Customer Experience Team
— Tech-billing on 09/14/2016
I've been reading up on URL variables - one use case that doesn't seem to be included here is UTM parameters for campaign tracking. Is it possible to pass campaign parameters from a URL (like source, medium, campaign) through with an individual survey response as hidden values?
Admin
— Bri Hillmer on 07/12/2016
@Susan: That's great news! I'm glad you were able to sort out how to use the URL variables!
Bri
Documentation Coordinator/Survey Sorceress
SurveyGizmo Customer Support
— Susan on 07/11/2016
Yep, this helps. We're also integrating with an Email Service Provider platform (Infusionsoft) via Zapier. Found that your URL variables are available in Zapier for mapping so didn't even need to map the variables to fields. Thank you!
Admin
— Bri Hillmer on 07/11/2016
@Susan: The email campaign contact fields are not available for mapping when using URL Variables though it sounds like you are not using our Email Campaigns anyway. If you wish to store the data being passed via URL variables to a First Name or Email question in your survey you can simply set up the Default Answer field to use the merge code for the URL Variable. This is covered in more detail in the below tutorial:
https://help.surveygizmo.com/help/article/link/using-url-variables-in-surveys#pre-populate-a-textbox-question
I hope this helps!
Bri
Documentation Coordinator/Survey Sorceress
SurveyGizmo Customer Support
— Susan on 07/11/2016
Thanks @bri.
Is there a way to map variables to SG fields? Namely email and firstname? I understand how to bring them in via a URL Variable.
Can we just map them on the action right to a SG field? I cannot control the variable names coming to SG. Example om_email trying to to go email.
Anything we can do within the action like [url("om_email")] => [contact("email")] or something?
Thanks!
Admin
— Bri Hillmer on 04/14/2016
@Wstallard: You are right Will! My apologies. URL variables return like so:
[[url("variable")]] => value
So, for example if I used the following URL variable in a response test=123 the surveyresponse would include the following in the return:
[[url("test")]] => 123
I updated the documentation accordingly. Thanks for catching this!
Bri
Documentation Coordinator/Survey Sorceress
SurveyGizmo Customer Support
— Wstallard on 04/13/2016
Hi.
@Bri: Please could you clarify how URL parameter values are returned via the API?
I don't see url parameters shown in the API docs you listed in your response to @Mike.
Thanks!
Will
Admin
— Bri Hillmer on 10/30/2015
@Gargi: If you've uploaded the user id and email address to the email campaign you don't even need to use URL Variables to access this data within the survey. They should be available automatically using the merge codes for the fields in the email campaign. Here is a tutorial with more information about how to use data uploaded to an email campaign in your survey:
http://help.surveygizmo.com/help/article/link/using-contact-data
I hope this helps!
Bri
Documentation Coordinator/Survey Sorceress
SurveyGizmo Customer Support
— Gargi on 10/30/2015
Hi I'm trying to pass data from my email campaign, and it is not working. Specifically I want to pass user id and email address to determine whom is responding to my survey (and how). But in the clicked URL, only the field names show and the data is not passing through. Client-Feedback?em=email&id=userid. I tried a couple of variations and I get the same result- the field name is being passed through not the data associated. Any ideas?
Admin
— Bri Hillmer on 09/29/2015
@Mike: Indeed they are! The are returned as part of the surveyresponse object. Here are 2 tutorials with more info:
http://apihelp.surveygizmo.com/help/article/link/surveyresponse-sub-object
http://apihelp.surveygizmo.com/help/article/link/surveyresponse-returned-fields
Thanks for checking out our documentation!
Bri
Documentation Coordinator/Survey Sorceress
SurveyGizmo Customer Support
— Mike on 09/29/2015
Hi,
Are URL Variables available via the Restful API?
Thanks,
Mike
Admin
— Bri Hillmer on 07/02/2015
@Jeff: Thanks for taking a look at our documentation! Great question! You can pass comma separated values in a URL variable. The entire string be stored automatically but, yes, if you wish to make use of the values you may want to use the default answer field in a Checkbox question to better leverage these values.
I should note, I did do some testing and the values would need to be comma separated not semicolon separated in order to populate the Checkbox question.
I hope this helps!
Bri
Documentation Coordinator/Survey Sorceress
SurveyGizmo Customer Support
— Jeff on 07/02/2015
Hi, is it possible to pass many value to a variable ? like ?q=toto;tata;titi ? Do i need to use an hidden checkbox control to store it ?