Merge Codes can be used throughout Alchemer to dynamically pull and display data previously entered in your survey or data from your account, email invitation, etc.
Thanks to the merge code helper (available throughout the Alchemer application), using merge codes in your surveys and email campaigns is easy!
How Do I Use Merge Codes in My Surveys?
Any time you wish to pull data from the answers your respondent previously provided (or their contact record in an email or sms campaign) you can do so using merge codes. You can find a Merge Code helper within the editor on text fields including question titles and instructions.
In other places, like Hidden Value Actions, default answer fields, and email campaigns look for the Select a Merge Code link below the text field to bring up the merge code tool:
You will see the following merge code tabs (located on the left):
- Pages & Questions* - reference previous question answers and specific answer options
- Email Invite Fields - refer to Email/SMS Campaign Contact Data within your survey
- About the Respondent - reference a respondent's edit link, URL variables, as well as geodata
- About the Survey - pull in information like the survey title and piping merge codes, among others.
- About Your Account - refer to your account information such as the account email address and organizational name
*Only questions from previous pages will be available for you to select.
If you know which tab your desired merge code is located in, click on that tab and once you locate the merge code, use the Insert link to the right to place the merge code at your cursor.
If you are not sure which tab your merge code resides in, use the Search bar to locate it. Search for keywords such as edit link, email, or search by question title if you are looking to find the merge code for one of your survey questions. The search is executed across all merge code categories i.e. Pages & Questions, About the Survey, About the Respondent, etc.
Merge Codes Available in Each Category
The bolded text below immediately following the opening bracket and ending before the opening parenthesis is the Merge Code category and defines the available properties (discussed in the next section).
[question("option value"), id="2"]*
*When using merge codes, make sure that you use straight quotes ("") as shown above. Do not use smart/curly quotes (“”) as these will break your merge codes. If you find that your merge codes look broken, it is likely due to the use of curly quotes. Recreate the merge codes with straight quotes and this should solve the problem.
There are 10 different categories. Below we list and describe each available merge code within each category:
- Question: Dynamically pull and display data from questions or actions.
- Quiz: Quiz score merge codes dynamically pull and display about how the respondent did.
- Page: Access information about a specific page of the survey.
- Invite: Pull data about a specific email campaign invitation or data unique to that invitation.
- Contact: Pull contact data from the specific contact; these work for either email invitation contacts, sms invitation contacts, or contacts within an account-level contact list.
- URL: Pull and displaying query string values.
- Survey: Pull data about a specific response or overall survey.
- System: Pull metadata about a survey response or from the Alchemer system.
- Account: Pull data about your Alchemer account.
- Template: Populate display settings in your HTML and CSS templates (link opens a separate article).
Question Merge Codes
value or option value
[question("value"), id="3"] or [question("option value"), id="2"]
These merge codes 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. This property is used when you'd like to pull the total value (answer) that came from a previous question. If this Merge Code is used on a multiple choice question, it will string all the piped values with a comma. For example, if a respondent answers options A and B, the output will be: A, B. These merge codes are interchangeable.
title or option title
[question("title"), id="2"] or [question("option title"), id="2"]
These merge codes 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. These merge codes are interchangeable.
If a question includes an other textbox either of these merge codes can be used to pull the text responses entered into the textbox.
other textbox merge code
[question("option value"), id="2", option="10001"] or [question("option value"), id="2", option="10001-other"]
These merge codes will pull the text response entered in an other textbox. The merge codes are interchangeable.
comment merge code
[question("comment"), id="2"]
This merge code will pull the response text from a comment element associated with a question (by question id).
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.
The answer count merge code will count other, write-in fields with a write-in response as 2 answers.
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.
Merge Codes for Pulling Data from Table Questions
If you are looking to pull data from a specific cell of a table you can do so using a Merge Code that includes the ID for the table row and the option SKU for the column.
The row and column headers below are labeled with the question IDs (for the row headers) and the option SKUs (for the column headers). This is just an example, you'll want to use a developer tool within your browser to inspect element and obtain your columns' option SKUs.
The below Merge Code will pull the data from the highlighted cell in the table above.
[question("value"), id="3", option="10004"]
Merge Codes for Pulling Data from Custom Table Questions
Custom table questions are popular for their ability to collect multiple data points in a concise manner. Trouble is, custom table questions are piped which makes the data difficult to access in the survey. Never fear! We've got a merge code for that too!
Here we cover a merge code that can be used to pull data from a single field in a Custom Table. This Merge Code will display column id 9 for a Custom Table question. Questionpipe will be set to "TableRow-x" where x refers to the table row number (the first table row is TableRow-0). ID will need to be the column id.
You can find the column ID# by editing the question. On the Question tab, right click next to the specific column within the Multiple Choice Options section and Inspect Element. Once you have accessed the Inspector, locate the number that follows "subquestion" i.e. "subquestion-9-title".
[question("value"), questionpipe="TableRow-0", id="9"]
Example:
For the above Custom Table your Merge Codes would be:
Column #1: Customers
- Row 1 - Enthusiasm: [question("value"), questionpipe="TableRow-0", id="9"]
- output: a
- Row 2 - Drive: [question("value"), questionpipe="TableRow-1", id="9"]
- output: b
Column #2: Employees
- Row 1 - Enthusiasm: [question("value"), questionpipe="TableRow-0", id="10"]
- output: b2
- Row 2 - Drive: [question("value"), questionpipe="TableRow-1", id="10"]
- output: c2
Page Piped Question Values
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 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.
[question("value"), pagepipe="marketing", id="3"]
Example:
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, let's say on Page 1: Sales respondents rate the sales team from 1-10. And on Page 2: Marketing they rate the marketing team 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
Custom Group Add as Needed Option
These complex and dynamic questions are actually piped. The below merge code will display the value of a sub-question within a specific add-as-needed group of a Custom Group question.
[question("value"), questionpipe="2", id="3"]
In the above example:
- id="3" is the ID# of the sub-question within a custom group
- questionpipe="2" is the second 'add as needed' set of answers chosen by the respondent (if they clicked the Add as Needed option one time)
Page Merge Codes
page title
[page("title")]
This merge code will display the page title of the page it resides on. This property does not require any attributes.
page ID
[page("id")]
This merge code will display the page ID (SKU) of the page it resides on. This property does not require any attributes.
page path
[page("pagepath")]
This merge code will display the page path of the respondent up to the page where this merge code is used. This property does not require any attributes.
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.
URL Variable Merge Codes
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 names!
Invite/Contact Merge Codes
Invite/Contact Merge Codes are used for pulling data from Email Campaigns and SMS Campaigns.
survey link
[invite(survey_link)]
This Merge Code will display the survey link that is being used in that email campaign. This link will be formatted as a hyperlink in the HTML version of a campaign message. You can click the Source button in the HTML editor to change Begin to whatever you'd like the link to say. This property does not require any attributes.
DO NOT modify this merge code in any way within your email or sms campaigns. If you wish to modify the text of the link in an Email Campaign, check out our Customize Email Campaign Link Text Tutorial to learn how!
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.
invite custom fields 1-10
[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.
unsubscribe link
[invite("unsubscribe link")]
This Merge Code will create an unsubscribe link in the footer of your email campaign inside of the Alchemer application. It is only available in the Email Campaign Footer Text and is required by CAN-SPAM ACT.
physical address
[account("physical address")]
This Merge Code will display the physical address attached to your account in Account > Account Summary inside of an email campaign's footer text.
[contact("email")]
This Merge Code will display the email address of a contact and recipient of an email or sms invitation through an email or sms campaign. This property does not require any attributes.
mobile phone
[contact("mobile phone")]
This Merge Code will display the mobile phone number of a contact and recipient of an email or sms invitation through an email or sms 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 or sms invitation through an email or sms 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 or sms invitation through an email or sms campaign. This property does not require any attributes.
address
[contact("street")]
This Merge Code will display the street name of a contact and recipient of an email or sms invitation through an email or sms campaign. This property does not require any attributes.
ste/apt
[contact("suite")]
This Merge Code will display the suite number or apartment number of a contact and recipient of an email or sms invitation through an email or sms 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 or sms invitation through an email or sms 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 or sms invitation through an email or sms 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 or sms invitation through an email or sms campaign. This property does not require any attributes.
postal code
[contact("postal")]
Both are interchangeable and will display the zip/postal code of a contact and recipient of an email or sms invitation through an email or sms campaign. This property does not require any attributes.
organization name
[contact("organization")]
This Merge Code will display the organization of a contact and recipient of an email or sms invitation through an email or sms campaign. This property does not require any attributes.
division
[contact("division")]
This Merge Code will display the division of a contact and recipient of an email or sms invitation through an email or sms 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 or sms invitation through an email or sms campaign. This property does not require any attributes.
team
[contact("team")]
This Merge Code will display the team of a contact and recipient of an email or sms invitation through an email or sms campaign. This property does not require any attributes.
group
[contact("group")]
This Merge Code will display the group of a contact and recipient of an email or sms invitation through an email or sms campaign. This property does not require any attributes.
role
[contact("role")]
This Merge Code will display the role of a contact and recipient of an email or sms invitation through an email or sms 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 or sms invitation through an email or sms 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 or sms invitation through an email or sms campaign. This property does not require any attributes.
phone (home)
[contact("home phone")]
This Merge Code will display the home phone of a contact and recipient of an email or sms invitation through an email or sms campaign. This property does not require any attributes.
phone (fax)
[contact("fax")]
This Merge Code will display the fax number of a contact and recipient of an email or sms invitation through an email or sms campaign. This property does not require any attributes.
phone (work)
[contact("work phone")]
This Merge Code will display the work phone of a contact and recipient of an email or sms invitation through an email or sms campaign. This property does not require any attributes.
custom field
[contact("customfieldname")]
This Merge Code will display the data stored in the custom field for the contact the contact management. Replace "customfieldname" with the actual custom field name in Contact Lists. This property does not require any attributes.
Survey Merge Codes
session id
[survey("session id")]
This Merge Code will display the session id of the current survey response. This property does not require any attributes.
Note: If you're looking for a unique identifier to pass to incentive rewards programs for your survey participant, this unique ID would be an excellent choice as it will ALWAYS be unique to that particular respondent.
survey id
[survey("id")]
This Merge Code will display the Alchemer assigned survey id for the current survey (useful for API interaction). 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. This link is not compatible with email campaign messages.
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 will 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. The Merge code additionally includes all elements that are assigned a Question ID (Section Navigator, Radio button Grid Rows, etc)
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 and partial responses for the current survey. This property does not require any attributes.
all responses
[survey("allresponses")]
This Merge Code will display the total number of all responses for the current survey (complete, partial, disqualified, and deleted). This property does not require any attributes.
complete responses
[survey("completeresponses")]
This Merge Code will display the total number of complete responses for the current survey. This property does not require any attributes.
partial responses
[survey("partialresponses")]
This Merge Code will display the total number of partial responses for the current survey. This property does not require any attributes.
deleted responses
[survey("deletedresponses")]
This Merge Code will display the total number of deleted responses for the current survey. This property does not require any attributes.
disqualified responses
[survey("disqualifiedresponses")]
This Merge Code will display the total number of disqualified responses for the current survey. 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.
surveycounter
[survey("counter")]
This merge code inserts a unique number for this survey that will increment each time the merge code is used.
Example: 1, 2, 3...
You can make this unique number safer to use in a long-running survey by adding the parameter "safer", which automatically adds in the numeric day of the year.
Example: [survey("counter"), safer="true"], which will output 441, 442, 443... because today is the 44th day of the year.
If you'd like control over the starting value, you can add the parameter "startat" to set a custom starting value for the counter.
Example: [survey("counter"), startat="1000"], which will output 1001, 1002, 1003...
Finally, if you need to use more than one counter in a survey, you can add the parameter "name=secondCounter", which creates a second counter which is unique from the first and referred to by the name "secondCounter". Make sure the name is unique, like "Counter2x", that you haven't used in a previous survey.
Example: [survey("counter"), name="secondCounter"]
The survey counter merge code is not compatible with embedded surveys and does not function in Preview/Test mode.
Quiz Merge Codes
The below quiz category merge codes (e.g. [quiz("questions correct")]) will ONLY work within the quiz score message itself.
score
[quiz("score")]
This will display the respondent's score (integer value). Pass/Fail & Tally Quizzes
totalquestions
[quiz("totalquestions")]
Displays the count of how many questions were scored Pass/Fail Quizzes ONLY!
questionscorrect
[quiz("questionscorrect")]
Displays the number of correctly answered questions. Pass/Fail Quizzes ONLY!
questionswrong
[quiz("questionswrong")]
Display the number of incorrectly answered questions. Pass/Fail Quizzes ONLY!
The below question category quiz merge codes (e.g. [question("quiz score"), id="2"]) work within the quiz score message and outside of the quiz score (e.g. send email actions).
quiz score
[question("quiz score"), id="2"]
This will display the total quiz score for both Tally and Pass/Fail Quizzes.
quiz total correct
[question("quiz total correct"), id="2"]
This will display the total number of correctly answered questions. Pass/Fail Quizzes ONLY!
quiz total wrong
[question("quiz total wrong"), id="2"]
This will display the total number of incorrectly answered questions. Pass/Fail Quizzes ONLY!
quiz passed
[question("quiz passed"), id="2"]
This will display whether or not the quiz was passed or failed. (True = Passed, False = Failed). Pass/Fail Quizzes ONLY!
quiz total questions
[question("quiz total questions"), id="2"]
This will display the total number of questions in your quiz. Pass/Fail Quizzes ONLY!
quiz message
[question("quiz message"), id="2"]
This will display the passing or failing message you set up inside your quiz score. Pass/Fail Quizzes ONLY!
quiz tally result
[question("quiz tally result"), id="2"]
For a Tally Quiz, this will display the quiz message for the range the respondent falls.Tally Quizzes ONLY!
Account Merge Codes
[account("email")]
This Merge Code will display the email address of the Alchemer account holder, based on the primary Account Information. This property does not require any attributes.
organization
[account("organization name")]
This Merge Code will display the organization of the Alchemer 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 Alchemer 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 Alchemer 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 Alchemer 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 Alchemer account holder, based on the primary Account Information. This property does not require any attributes.
zip or postal
[account("postal")]
Both are interchangeable and will display the zip/postal code of the Alchemer 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 Alchemer 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 Alchemer account holder, based on the primary Account Information. This property does not require any attributes.
physical address
[account("physical address")]
This Merge Code will display the physical address attached to your account from Account > Account Summary inside of an email campaign's footer text.
System Data Merge Codes
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 go to Format and Transform Data in Merge Codes to learn more!
referrer
[system("referrer")]
This Merge Code will display the link which the user was referred from to your survey.
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 or 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 or 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 or 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.
[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.
Merge Codes in Translations
In multi-language surveys if you plan to use merge codes to dynamically pull previous answers you'll need to make sure to use the title merge code in order to pull the correct language.
[question("title"), id="3"], [question("piped title")] , and [page("piped title")] - Will all pull the appropriate language in multi-language surveys.
[question("value"), id="3"], [question("piped value")] , and [page("piped value")] - Will all pull the default language in multi-language surveys.
Merge Codes in Reports and Exports
Because merge codes populate with a dynamic value for each response, when the results are summarized, there is not a way to aggregate these values. As a result, the merge code displays in reports
How Can I Fix This?
If you wish to change this within the Standard Report you can edit each question that uses simple piping and customize the Headline to display something more meaningful. To do so, click the Chart Type option to edit each element within the Standard Report.
Delete or customize the text of the merge code in the Title field and click Save. Repeat for all questions that use simple piping within your survey.
In order to address this in a CSV/Excel Export of your raw data, this would need to be edited manually within Excel.
Considerations
- When using merge codes, make sure that you use straight quotes (""). This will be the default if you insert merge codes using the merge code helper tool.
- Do not use smart/curly quotes (“”) as these will break your merge codes. If you find that your merge codes look broken, it is likely due to the use of curly quotes. Recreate the merge codes with straight quotes and this should solve the problem.
Free Individual SurveyGizmo Enterprise*
*Excludes Stakeholder
Feature | Included In |
---|