To populate data from a URL parameter into a data field, use the url_param
method. Unlike getParm
, url_param
will work on any page to populate data included in a survey entry link via a URL parameter into a survey variable as long as the reference is correctly formulated. This is possible because the url_param
method is not looking at the current page URL. Rather, it is looking at the system variable 'entry_url' which by default captures and stores the link the respondent uses to enter the survey, parameters and all. This allows for far greater flexibility than getParm
with regards to populating survey data. Additionally, url_param
is not case sensitive. So, in the event that a panel provider uses all upper case, all lower case, or some combination thereof in the url parameter label that you must capture, url_param
will be successful.
Tip! For information on how to form your entry links to capture parameters, see Passing in parameters.
Examples
To grab information from a survey entry link URL using url_param
, you must set up a variable to capture it and store it. Each individual parameter needs a question to capture the value. The type of data being passed in will determine the type of variable you need to capture it. Use the url_param
expression with dvalue
or cvalue
to match and store the value from the parameter in the URL with the same name. In the examples below the letter 'n' is used for the "first name" parameter, and the word 'pan' is used for the "panel" parameter.
Open-end data
To capture open-end data, for instance letters like in a name, use a type: text
question to capture and store a string:
# Entry URL example
# http://servername.intellisurvey.com/pub/survey_ID/record_ID?n=Jeff
F_NAME. Respondent First Name Passed In invisible: y type: text cvalue: url_param('n')
Closed-end data
To capture closed-end data, for instance a numeric value, use a type: radio
question where each number can be used to classify information:
# Entry URL example
# http://servername.intellisurvey.com/pub/survey_ID/record_ID?pan=1
PANEL. Panel Identifier invisible: y type: radio cvalue: url_param('pan') 1. Panel 1 2. Panel 2
Usage with multi-select variables
url_param
can also punch multiple options with a type: checkbox
question. You have to pass each parameter one at a time by repeating the parameter in the entry URL (invite links) as shown below. In this example, QPRODUCT will punch both options 1 and 3, or Toaster oven and Blender, respectively.
# Entry URL example
# http://servername.intellisurvey.com/pub/survey_ID/record_ID?t=1&t=3 PRODUCT. Products Purchased type: checkbox invisible: y cvalue: url_param('t') 1. Toaster oven 2. Microwave 3. Blender setconditionedtext: PURCHASE 1. purchase {if countChecked($QPRODUCT) == 1} 2. purchases {if countChecked($QPRODUCT) > 1} newpage This survey will ask about your recent [* lc get_phrase('QPRODUCT') *] __PURCHASE__.
Tip! Because url_param
uses the system variable 'entry_url', it can be used on variables anywhere in the survey, not just at the beginning, as is the case with the above example.
Conditional syntax
As with any cvalue
expression, url_param
can be used with conditional syntax ("if" and "else" statements). In the following example, option 99 is punched if the 'pan' parameter is absent from the URL.
PANEL. Panel Identifier invisible: y type: radio cvalue: if (url_param('pan')) {url_param('pan')} else {99} 1. Panel 1 2. Panel 2 99. No Panel Specified
Comments
0 comments
Please sign in to leave a comment.