Skip to main content

How to Use Conditional Text in Document Generation

With Document Studio, you can mark specific paragraphs or sections of your document as conditional content. This means that the content will only be included in the generated document if a certain condition is met. This is useful if you want to include different content in your document based on user's answers that may come from a Google Form or a Google Sheet.

For instance, if the user's country is the United States, you can include a paragraph about US tax laws. If the user has selected their country as Japan, you may show the text written in Japanese and hide the English text.

Conditional Content is currently supported in Google Documents and Email Templates only.

How to Use Conditional Content in Google Documents

To add conditional content in your Google Document, you need to wrap the content inside a pair of special IF tags.

<<If: ({{Country}} = "Japan")>>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Class aptent taciti sociosqu ad.
<<EndIf>>

Learn more - How to Use Conditional Content in Google Documents

How to Use Conditional Content in Email Templates

To add conditional content in email templates, you need to wrap the content inside a pair of special IF tags.

{% assign name = "{{Country}}" %}
{% if name == "Holland" or name == "Netherlands" %}
The flag of {{Country}} is 🇳🇱
{% endif %}

In addition to conditional content, you can also add dynamic content in email templates using the special Scriptlets templating language.