Skip to main content

How to Use Merge Fields or {{Markers}} in Templates

Document Studio lets you create personalized documents and emails from templates. These templates include merge fields, enclosed in double curly braces, to personalize your documents and email messages with information from the data source which could either be a Google Sheet or a Google Forms response.


If you have previously from a different document generation solution, that app could have used a different name to identify merge fields. They could be called Template Tags, Placeholders, Markers, or maybe just Variables.

Merge Fields Exampleโ€‹

Merge Fields indicate where should the app populate dynamic information in your document and where that information should come from. Document Studio will replace all merge fields in your template with actual input data from Google Sheets (or Google Forms) to generate the output document.

For instance, if a question in your Google Form says What is your name, the marker that will be used in the email or document template will be {{What is your name}}.

Let's start with a simple template.

{{ Common Name }} belongs to the family of {{ Family Name }} plants and itโ€™s scientific name is {{ Scientific Name }}

The above template contains three merge fields, Common Name, Family name and Scientific Name, and they can be easily recognized since the fields are surrounded with double curly braces.

Merge Field Markers

Formula Markersโ€‹

You can create additional columns in the source Google Spreadsheet with formulas and use the column titles as markers in your template.

The spreadsheet contains a column called Invoice Number that contains the unique invoice number for each row generated by an Array Formula using the invoice date and the position of the row in the spreadsheet.

IF(ROW(A:A)=1,"Invoice Number",
IF(ISBLANK(A:A),"", "DI/"&RIGHT(REPT(0,5)&ROW(A:A),5)&"/"&YEAR(B:B))))

The above formula will generate a unique invoice number for each row in the spreadsheet as long as there are no blank rows. If there are blank rows, the formula will generate a blank cell. You can now use the marker {{ Invoice Number }} in your template though it was not available in the source spreadsheet.

Unique Invoice Numbers

Rules of Merge Fieldsโ€‹

There are a few simple rules you should follow when using merge fields in templates.

  1. A merge field must be enclosed in double curly braces always.
  2. A merge field can be inserted multiple times in the same template.
  3. Each merge field in the document template should map to a column in the data source else that field will be replaced with an empty string.
  4. If you are merging data from Google Sheets, the column headers on your spreadsheet must exactly match the merge field names in your template.
  5. If you are merging data from Google Forms, the question titles on your form must exactly match the merge field names in the document template.
  6. Use the special Embed syntax to embed images, QR Codes, and dynamic charts in your document and emails.
  7. Use Scriptlets to manipulate dynamic content into your emails and support apps.

Markers for Google Formsโ€‹

In addition to standard form question titles, Google Forms also provide several built-in markers. These include:

  • {{Row Number}} - The position of form response in the entire collection of responses.
  • {{Response Number}} - The current count of responses in Google Forms
  • {{Form Name}} - The title of the Google Form
  • {{Form Url}} - The link of the Google Form where responses can be submitted
  • {{Form Id}} - The unique ID of the Google Form assigned by Google Drive
  • {{Response Id}} - A unique ID that is internally assigned to every response by Google Form
  • {{Response Url}} - Direct link to view or edit the current form submission.
  • {{Response Date}} - The full timestamp when a form was submitted
  • {{Respondent Email}} - If your Google Form is capturing email addresses, this contains the email of the form respondent.
  • {{All Answers}} - An HTML table containing all the completed form responses. Unanswered questions are not included.
  • {{Full Response}} - An HTML table containing all form responses. Unanswered questions are included.
  • {{Quiz Score}} - The score of the quiz if you have a quiz in your Google Form.
  • {{Quiz Score Percent}} - The percentage score of the Google Form quiz.
  • {{Total Quiz Points}} - The maximum points that can be scored in Google Form quiz.

The {{All Answers}} and {{Full Responses}} markers for Google Form responses will only work inside email templates. These markers cannot be used inside document templates.