Survey Expert Ryan Farmer observes that many well-known companies aren’t branding their surveys, and discusses why survey design is hyper-important when you want to gather customer feedback.
Table of Contents
Merge Codes
Version 3.x Instructions
Optional: Go to the SurveyGizmo version 2.x instructions
Merge codes are specially formatted text that can be used throughout the application to dynamically show content related to your survey, account, invitation, etc. However, to use merge codes does not require a large amount of studying or practice; 95% of the time you only need to use one thing, the Merge Code Helper:

When editing any question, descriptive text, and Hidden Value action you have the opportunity to use the Merge Code helper by clicking the Insert Merge Code link in the bottom right, bringing up the Select a Merge Code dropdown menu:


By selecting an item from the dropdown menu, the merge code for that particular item will be visible for you to click (insert at your cursor) or copy & paste into the textbox above.

This is the simplest method of working with merge codes as well as a great starting place before making any modifications (rather than writing a merge code from scratch). For advanced users who are looking for more flexibility and options, an amazing world awaits you…
The Basic Structure of a Merge Code
Below is a very commonly formatted merge code which will be used as example to break down all the different parts of a merge code:
[question("option value"), id="2"]
All merge codes follow this similar structure, always starting and ending in square brackets [ ] and containing a section in parenthesis surrounding double quotation marks (” “). Finally, all the major areas of the merge code (covered below) should always be written in all lowercase letters. Let’s breakdown each part of the merge code.
Merge Code Category
[question("option value"), id="2"]
The highlighted section above is the beginning of the merge code, immediately following the opening square bracket and ending before the opening parenthesis. This is the merge code category and defines not only the general area that this merge code will represent, but it also defines the possible properties that are available (discussed in the next section). There are 9 different categories:
- question: From questions or actions within the survey itself
- page: Accessing information about that page of the survey; used for page piping
- invite: Data about a specific email campaign invitation or data unique to that invitation
- contact: Data from the specific contact; related to email invitation campaigns
- url: Displaying query string values based on the variable name
- survey: Top level survey information about the specific response or overall survey
- system: Meta data about the respondent or SurveyGizmo’s system
- account: Data about your SurveyGizmo account, configured under Account Settings
- template*: Survey and report theme
* The template category will not be covered in this tutorial as it has its own separate tutorial due to its advanced integration, uses, and syntax.
Merge Code Property
[question("option value"), id="2"]
The highlighted section above is the property, found between the double quotation marks within the parenthesis. What can be used as a property is limited to what is made available within the merge code category and like the category, must be all lowercase text. If you think of a category as the city in a mailing address, then the property is the street address.
Merge Code Attributes
[question("option value"), id="2"]
The highlighted section above is an attribute of the merge code and is matched to the specific property. If the property is the street address of a mailing address, the attributes are the house/apartment/suite number. However, unlike the category and property, you can have none or multiple attributes, all separated by commas in the latter case. Attributes are always paired as an identifier and its value:
id="2"
In the example above, ‘id’ is the identifier and the value is inside double quotation marks. They are connected by an equals sign.
The following survey invitation link will demonstrate many different merge codes in action:
http://s-a18667-i.sgizmo.com/s3/i-15555813-85409/
Properties Available in Each Category
Within each category there are specific properties available. Each possible property will be listed and their description below.
Question Category
We have some new merge codes we wanted to share with you. You can find them in our main merge code tutorial as well: https://support.surveygizmo.com/entries/448889-merge-codes-simple-piping
Question Value
[question("value"), id="3"]
This special merge code property is used when you’d like to pull the total value (answer) that came from a previous question. You must include the id attribute to specify which question id you are retrieving (in the above example, we are using Question ID#3) If this merge code is used on a multiple choice question, it will string all the piped values with a comma.
Ex: If a person answers options A and B, the output will be: A, B
Question Value to a List
[question("value"), id="3", delimiter="<li>"]
This merge code is used to pull the total value (answer) of a previous question, and it will string all piped values with an HTML <li>tag. You must include the id attribute to specify which question id you are retrieving (in the above example, we are using Question ID#3)
Ex: If a person answers options A and B, the output will be:
A
B
Question Value with “Or” from Checkbox
[question("value"), finaldelimiter="or", id="3"]
This merge code will pipe values (answers) from a checkbox question, string them, and add an “or” before the last piped value.
Ex: If your checkbox questions output as:
a,b,c,d,e
then merge code will output as:
a, b, c, d, or e
Custom Group Add as Needed Option
[question("value"), questionpipe="2", id="3"]
This merge code will display the value of a sub-question within a specific add as needed group of a Custom Group Question.
Ex: In the above example:
id=”3″ is the ID# of the sub-question within a custom group
questionpipe=”2″ is the third ‘add as needed’ set of answers chosen by the respondent (if they hit add as needed 2 times)
Custom Matrix Row Piping
[question("value"), questionpipe="Drive", id="4"]
This merge code will display column id 4 for a custom table question. (You can find the column ID# by editing the question, inspecting element where it says “sub-questions”(columns) and then taking the first two values that show up. Here’s a screenshot: http://screencast.com/t/rNckUn93Gn)
- Questionpipe will need to be the row header (case sensitive).
- ID will need to be the column id#
Example, if your custom table looks like the following

Your merge codes would be:
Column # 1
[question("value"), questionpipe="Drive", id="4"]
[question("value"), questionpipe="Enthusiasm", id="4"]
Column #2
[question("value"), questionpipe="Drive", id="10"]
[question("value"), questionpipe="Enthusiasm", id="10"]
the output will be (You can replace Column 1 and 2 with anything you’d like):
Column # 1
a
b
Column #2
b2
c2
Page Pipe Question Values
[question("value"), pagepipe="marketing", id="3"]
This merge code property is used to pull the values of a page that has been piped. It will display the reporting value of the question ID id indicated in the id attribute (this is the question ID of the question on the piped page you’d like to show up). It will also string all the piped values with a comma.
–This will generally be used in send email actions, or later in the survey, when you’d like to know what answers were given for a specific piped page.
Ex: If you have a question that asks someone to rate their top two departments, when you page pipe those, you’ll get one for each.
So lets say Page 1: Sales (and you rate them 1-10)
and Page 2: Marketing (and you rate them 1-10)
On your thank you page or inside your send email action, you would put something like:
Marketing Results: [question("value"), pagepipe="marketing", id="3"]
Sales Results: [question("value"), pagepipe="sales", id="3"]
.. and we’ll say you got 10 for marketing, and 5 for sales
The output would be:
Marketing Results: 10
Sales Results: 5
option title
title
[question("option title"), id="2"]
Both are interchangeable and will display the title of the answer given. This is the answer title that is visible to the respondent. You must include the id attribute to specify which question id you are retrieving.
option value
value
[question("option value"), id="2"]
Both are interchangeable and will display the reporting value of the answer given. This is the answer value that is not visible to the respondent and may be set differently than the title. You must include the id attribute to specify which question id you are retrieving.
piped title
[question("piped title")]
This special merge code property is only used within a question or descriptive text that is piped. It will display the answer title of the current iteration of the piped question. This is the answer title that is visible to the respondent. This property does not require any attributes.
piped value
[question("piped value")]
This special merge code property is only used within a question or descriptive text that is piped. It will display the reporting value of the current iteration of the piped question. This is the answer value that is not visible to the respondent and may be set differently than the title. This property does not require any attributes.
answer count
[question("answer count"), id="2"]
Useful with multiple selection questions such as a checkbox question, this property will display the total count of answers that were selected in the question. You must include the id attribute to specify which question id you are retrieving.
question number
[question("question number"), id="2"]
This property will display the question’s question number (including period) and can be used in referencing a previous question by number when you have a dynamically numbered survey (logic showing and hiding questions). You must include the id attribute to specify which question id you are retrieving.
Page Category
piped title
[page("piped title")]
This special merge code property is only used within a page that is piped and can be used in any question or descriptive text within that page. It will display the answer title of the current iteration of the piped question. This is the answer title that is visible to the respondent. This property does not require any attributes.
piped value
[page("piped value")]
This special merge code property is only used within a page that is piped and can be used in any question or descriptive text within that page. It will display the reporting value of the current iteration of the piped question. This is the answer value that is not visible to the respondent and may be set differently than the title. This property does not require any attributes.
Invite Category
survey link
[invite("survey link")]
This merge code will display the survey link that is being used in that email campaign. This property does not require any attributes.
messageid
[invite("messageid")]
This merge code will display the unique id given to the specific invitation recipient in an email campaign (this id is appended to the survey link). This property does not require any attributes.
custom 1
custom 2
custom 3
custom 4
custom 5
[invite("custom 1")]
This merge code will display the corresponding custom field number from the invite recipient in an email campaign. This property does not require any attributes.
Contact Category
[contact("email")]
This merge code will display the email address of a contact and recipient of an email invitation through an email campaign. This property does not require any attributes.
first name
[contact("first name")]
This merge code will display the first name of a contact and recipient of an email invitation through an email campaign. This property does not require any attributes.
last name
[contact("last name")]
This merge code will display the last name of a contact and recipient of an email invitation through an email campaign. This property does not require any attributes.
organization
[contact("organization")]
This merge code will display the organization of a contact and recipient of an email invitation through an email campaign. This property does not require any attributes.
department
[contact("department")]
This merge code will display the department of a contact and recipient of an email invitation through an email campaign. This property does not require any attributes.
home phone
[contact("home phone")]
This merge code will display the home phone of a contact and recipient of an email invitation through an email campaign. This property does not require any attributes.
work phone
[contact("work phone")]
This merge code will display the work phone of a contact and recipient of an email invitation through an email campaign. This property does not require any attributes.
fax
[contact("fax")]
This merge code will display the fax number of a contact and recipient of an email invitation through an email campaign. This property does not require any attributes.
street
[contact("street")]
This merge code will display the street name of a contact and recipient of an email invitation through an email campaign. This property does not require any attributes.
suite
[contact("suite")]
This merge code will display the suite number of a contact and recipient of an email invitation through an email campaign. This property does not require any attributes.
city
[contact("city")]
This merge code will display the city of a contact and recipient of an email invitation through an email campaign. This property does not require any attributes.
state
region
[contact("state")]
Both are interchangeable and will display the state or region of a contact and recipient of an email invitation through an email campaign. This property does not require any attributes.
zip
postal
[contact("zip")]
Both are interchangeable and will display the zip/postal code of a contact and recipient of an email invitation through an email campaign. This property does not require any attributes.
country
[contact("country")]
This merge code will display the country of a contact and recipient of an email invitation through an email campaign. This property does not require any attributes.
job title
[contact("job title")]
This merge code will display the job title of a contact and recipient of an email invitation through an email campaign. This property does not require any attributes.
website
[contact("website")]
This merge code will display the website of a contact and recipient of an email invitation through an email campaign. This property does not require any attributes.
URL Category
The property for the URL category is not a set value like other categories, but rather dependent on the variable being sent through the query string to the survey. The below example would pull the value of the test variable:
Sample Query String: ?test=val
Sample Merge Code: [url("test")]
If the query string variable was TEST, the above merge could would still work properly as it ignores the case of the query string variable. However, the merge code must always use lowercase property names!
Survey Category
response id
session id
[survey("response id")]
Both are interchangeable and will display the response/session id of the current survey response. This property does not require any attributes.
edit link
[survey("edit link")]
This merge code will display the unique edit link to edit the current survey response. This property does not require any attributes.
title
[survey("title")]
This merge code will display the survey title of the current survey. This property does not require any attributes.
close date
[survey("close date")]
This merge code will display the date the current survey link with close. If no date is set, it will display the current date. This property does not require any attributes.
language
[survey("language")]
This merge code will display the language being used for the current survey response. This property does not require any attributes.
total pages
[survey("total pages")]
This merge code will display the total number of pages in the current survey. This property does not require any attributes.
total questions
[survey("total questions")]
This merge code will display the total number of questions in the current survey. This property does not require any attributes.
time taken
[survey("time taken")]
This merge code will display the total amount of the time the respondent has taken to reach the page where this merge code is present, displayed in seconds. This property does not require any attributes.
total responses
[survey("total responses")]
This merge code will display the total number of completed or partial responses for the current survey. This property does not require any attributes.
id
[survey("id")]
This merge code will display the SurveyGizmo assigned survey id for the current survey (useful for API interaction). This property does not require any attributes.
basic page count
[survey("basic page count")]
This merge code will display the number of pages visited by the respondent so far, including the current page. This includes counting each iteration of a page that is page piped. Finally, it will not count navigation to pages you have already visited.
For instance, if you start on page 1, get jumped to page 3, hit ‘previous page’ and return to page 1, change an answer and get jumped to the Thank You page, you will have a total of 3 if the Thank You page has this merge code.
System Category
time
[system("time")]
This merge code will display the current time in the US Eastern timezone. This property does not require any attributes.
date
[system("date")]
This merge code will display the current date (in the US Eastern timezone). The default format is MM/DD/YYYY but can be altered with the format attribute (covered in the attributes section). However, this property does not require any attributes.
ip
[system("ip")]
This merge code will display the IP address of the respondent in the current survey response, if available. This property does not require any attributes.
browser
user agent
[system("browser")]
Both are interchangeable and will display the browser type/user agent string of the respondent in the current survey response, if available. This property does not require any attributes.
country
[system("country")]
This merge code will display the country of the respondent in the current survey response based on the geolocation data retrieved from their IP address, if available. This property does not require any attributes.
state
[system("state")]
This merge code will display the state of the respondent in the current survey response based on the geolocation data retrieved from their IP address, if available. This property does not require any attributes.
region
[system("region")]
This merge code will display the region of the respondent in the current survey response based on the geolocation data retrieved from their IP address, if available. This property does not require any attributes.
city
[system("city")]
This merge code will display the city of the respondent in the current survey response based on the geolocation data retrieved from their IP address, if available. This property does not require any attributes.
zip
postal
[system("postal")]
Both are interchangeable and will display the zip/postal code of the respondent in the current survey response based on the geolocation data retrieved from their IP address, if available. This property does not require any attributes.
longitude
long
[system("longitude")]
Both are interchangeable and will display the longitude of the respondent in the current survey response based on the geolocation data retrieved from their IP address, if available. This property does not require any attributes.
latitude
lat
[system("latitude")]
Both are interchangeable and will display the latitude of the respondent in the current survey response based on the geolocation data retrieved from their IP address, if available. This property does not require any attributes.
Account Category
[account("email")]
This merge code will display the email address of the SurveyGizmo account holder, based on the primary Account Information. This property does not require any attributes.
organization
[account("organization")]
This merge code will display the organization of the SurveyGizmo account holder, based on the primary Account Information. This property does not require any attributes.
street
[account("street")]
This merge code will display the street address of the SurveyGizmo account holder, based on the primary Account Information. This property does not require any attributes.
suite
[account("suite")]
This merge code will display the suite address of the SurveyGizmo account holder, based on the primary Account Information. This property does not require any attributes.
city
[account("city")]
This merge code will display the city address of the SurveyGizmo account holder, based on the primary Account Information. This property does not require any attributes.
region
[account("region")]
This merge code will display the region of the SurveyGizmo account holder, based on the primary Account Information. This property does not require any attributes.
zip
postal
[account("postal")]
Both are interchangeable and will display the zip/postal code of the SurveyGizmo account holder, based on the primary Account Information. This property does not require any attributes.
country
[account("country")]
This merge code will display the country of the SurveyGizmo account holder, based on the primary Account Information. This property does not require any attributes.
public phone
[account("public phone")]
This merge code will display the public phone number of the SurveyGizmo account holder, based on the primary Account Information. This property does not require any attributes.
Attributes Available
In most cases, the question category will make the most use of attributes. However, where logical, many attributes can be used in many categories and properties. Below is a list of attributes and their usage, including a common example merge code format. Remember, multiple attributes can be used together if separated by commas.
id
[question("option title"), id="2"]
The id identifier is used for a particular question id will be accessed by the property, specified as a numeric value. Rows in a table, for instance, all have their own unique question id which can be used to get the results from only a single row of a table.
option
[question("option value"), id="2", option="10004"]
The option identifier is used for a particular question’s answer id, specified as a numeric value. To use the option attribute, you must specify an id attribute as well. In a List of Textboxes, the option attribute allows you to access a particular row in the list (as each ‘row’ is actually an option id rather than a unique question id such as with tables). Note: If the answer was not selected or filled out (in the case of an open textfield or ‘row’ in a List of Textboxes), the merge code will not return anything.
delimiter
[question("option value"), id="2", delimiter=";"]
The delimiter identifier is used to choose the separating mark in a list of multiple answers specified by the id attribute. The id attribute is required when using delimiter attribute. By default, if no delimiter is specified, a comma ( , ) is used to separate each answer, for instance in a checkbox question. The delimiter can be any text or html, such as using the HTML <br /> tag as the delimiter. NOTE:The questiondelimiter attribute should be used if the id specified is a table question (not a specific row).
questiondelimiter
[question("option value"), id="2", questiondelimiter="; "]
The questiondelimiter identifier is used to choose the separating mark for rows within a table, specified by the id attribute. The id attribute is required when using questiondelimiter attribute. By default, if no questiondelimiter is specified, an HTML break ( <br /> ) is used to separate each row, for instance in a table of checkbox questions. NOTE:The questiondelimiter attribute can be combined with the delimeter attribute to change the formatting between rows as well as between multiple answers within a particular row.
numberformat
[question("option value"), id="2", numberformat="2"]
The numberformat identifier is used to determine the number of decimal places, specified as 0 or positive numeric value. To use the numberformat attribute, you must specify an id attribute as well. If the numeric value is larger than the number of decimal places in the answer, zeros will be used. If the numeric value has less than the number of decimal places in the answer, rounding will occur: 158.16 with numberformat=”1″ will result in 158.2. This is best used on open answer question types.
stringformat
[question("option value"), id="2", stringformat="%d sheep"]
ADVANCED USERS ONLY The stringformat identifier has its own language and is extremely powerful. It is based on the PHP sprintf() function and you can see examples of it in this PHP sprintf function tutorial. This is best used on open answer question types.
case
[question("option value"), id="2", case="upper"]
The case identifier is used to choose the case of the text in the question, specified by the id attribute. There are three possible values for the case attribute:
- upper – Change the answer to all uppercase
- lower – Change the answer to all lowercase
- proper – Change the answer to all proper case (first letter of first word in sentence)
An id attribute must be specified.
default
[question("option value"), id="2", default="Yes"]
The default identifier is used to set a default output to display if the merge code would display nothing. The value should represent the exact text that should be displayed by default. NOTE: If you default attribute’s value includes double quotation marks, they need to be escaped by placing a backslash prior to the double quotation mark: default=”Bob said, \”Giddy Up!\”"
displaytitle
[question("option value"), id="2", displaytitle="true"]
The displaytitle identifier is used to display the question’s title, specified by the id attribute. The value should be set as “true” if it is used. An id attribute is required to use the displaytitle attribute.
optiontitle
[question("option value"), id="2", option="10004", optiontitle="true"]
The optiontitle identifier is used to display both the title and reporting value of a specific question’s answer, specified by the id attribute and option attribute, respectively. The value should be set as “true” if it is used. An id attribute and option attribute are required to use the optiontitle attribute.
replace
[question("option value"), id="2", replace="yes", with="no"]
The replace identifier is used to specify text that should be replaced and must be used in conjunction with the with attribute. There can only be one replace attribute in a single merge code (multiple instances will ignore all but the last instance of replace).
with
[question("option value"), id="2", replace="yes", with="no"]
The replace identifier is used to specify text that should go in place of the text specified in the replace attribute. There can only be one with attribute in a single merge code (multiple instances will ignore all but the last instance of with).
urlencode
[question("option value"), id="2", urlencode="true"]
The urlencode identifier is used to translate the text into a format that can be placed directly into a URL. This can be used to build a query string and link dynamically and properly formatted. The value should be set as “true” if it is used.
urldecode
[question("option value"), id="2", urldecode="true"]
The urldecode identifier is used to translate the text from a URL format into normal text. This will reverse the urlencode attribute. The value should be set as “true” if it is used.
Version 2.x Instructions
An example of a merge code is:
[%%12:question%%]
This represents the Reporting Value for a question that is stored by SurveyGizmo from the survey (a.k.a. the respondent’s answer). It can be used as part of piping, email auto-responders, and even when redirecting the browser in the query string. The merge code syntax is also used in other systems within SurveyGizmo, such as email invitations.
To find the merge code within the survey, there are two options: Use the Simple Piping Wizard or find the Question ID and manually create the merge code.
- Use the Simple Piping Wizard
- Go to a question that is after the question you wish to evaluate as part of the rule and click the Advanced Edit icon (the little notebook on the left side of the question). When the question opens up, on the right side of the Question Title box you will see a smaller box that includes the Simple Piping Wizard. Click the link at the bottom of that box that is labeled ‘Select a Variable’. A drop-down box will appear. Select the question from the list and a merge code will appear under the box. Copy that merge code and add it to your rule.
- Create the Merge Code manually
-
Go to the specific question which you wish to evaluate in the rule and click the Advanced Edit icon (the little notebook on the left side of the question). When the question opens up, on the right side of the Question Title box you will see a smaller box which includes the Question ID. To create the merge code, use the following format:
[%%xx:%%]
xx represents the question ID found in the question editor, e.g. [%%23:%%]
To clarify, the code is a left square bracket ( [ ), two percentage signs ( %% ), the question ID, a colon ( : ), two percentage signs ( %% ), and a right square bracket ( ] ).
- What if there is no Question ID, such as a Quiz Score or Hidden Value action?
- Don’t worry, there is still a Question ID, it is just less obvious to find. To find the Question ID, click the Advanced Edit button for the action or question. Then, look at the browser’s address/URL bar at the top. It would be similar to the following:
http://app.sgizmo.com/surveybuilder/survey_question_editor.php?sid=12345&qid=63&qnum=1
You will see a variable called qid, following by an equals sign and then the Question ID: 63 in the above example. Now you can use the method outlined in option 2 above to create your merge code!
- For a table/matrix, each row has a Question ID assigned to it. To get the question ID, edit the table (notepad icon), and hover your mouse over the textbox for the particular row header, and text will appear below your mouse that will notify you of the Question ID for that row.
- Don’t worry, there is still a Question ID, it is just less obvious to find. To find the Question ID, click the Advanced Edit button for the action or question. Then, look at the browser’s address/URL bar at the top. It would be similar to the following:
-
Multi-Textbox (List of Textboxes), Star Ranking (Tables) and Continuous Sum Questions
These special questions also have special merge codes which can be used within Question Titles, Hidden Value fields, and Descriptive Text Fields. These special merge codes are not currently compatible within Email Auto-Responders (store them in a Hidden Value field first). This merge codes allow you to pull the contact from one row/textbox within the question. The rows are numbered from top to bottom starting from zero (0) and counting up: 0, 1, 2, 3 would be the first 4 rows of a list of textbox or continuous sum question. The format is similar to the regular merge code, however the following is added after the question id number: an underscore, the capital letter O, and the row number.
Examples:
- [%%12_O0: Do you %%]
- [%%412_O1:%%]
- [%%7_O2:%%]