How to Build Conditional Google Docs Templates That Adapt to Your Data
How to Build Conditional Google Docs Templates That Adapt to Your Data
Meta description: Build smart Google Docs templates that show different content based on your data. Complete guide to conditional logic, if-then statements, and dynamic templates that adapt automatically.
---
Every business hits this problem: you need 3 versions of the same proposal template (basic, standard, premium) or 5 versions of the same contract (industry-specific terms for healthcare, finance, retail, etc.).
Managing multiple template versions is a nightmare. Update pricing? Edit 5 files. Change a clause? Find and replace across dozens of docs. Miss one version, and you send outdated content to clients.
There's a better solution: conditional templates. One template that adapts based on your data, showing different content for different scenarios.
This guide shows you exactly how to build conditional Google Docs templates—from simple if/else logic to complex multi-condition rules—so you maintain one template instead of 20.
Why Conditional Templates Matter
Traditional static templates force you to choose: create separate templates for every variation, or manually edit after generating. Both waste time.
Scenario: A consulting firm offers three service tiers (Basic, Professional, Enterprise). Each proposal includes different deliverables and benefits.
Bad approach: Three separate proposal templates
Good approach: One template with conditional logic
Real-World Use Cases
Sales proposals: Show premium features only for premium tier clients Legal contracts: Include industry-specific compliance clauses automatically HR documents: Different benefit packages based on employee level Client reports: Custom sections for different service types Invoices: Payment terms vary by customer credit status Onboarding packets: Content adapts to role (manager vs individual contributor)
Any time content varies based on data, conditional templates eliminate manual editing.
The Basics: How Conditional Logic Works
Conditional templates use if-then statements (just like programming, but simpler):
Format:
``
{{#if Condition}}
Content shown when condition is true
{{/if}}
`
Real example:
`
{{#if Service Tier == "Premium"}}
PREMIUM BENEFITS
As a Premium client, you receive:
• Dedicated account manager
• Priority 24/7 support
• Monthly strategy calls
• Quarterly business reviews
{{/if}}
`
What happens:
One template → dynamic content.
Step 1: Design Your Data Structure
Before building conditional templates, plan your data.
Identify Your Variables
List what makes content vary:
Structure Your Spreadsheet
Example: Proposal data for conditional template
| Client Name | Service Tier | Industry | Rush Delivery | Discount Eligible | |-------------|--------------|----------|---------------|-------------------| | Acme Corp | Premium | Healthcare | Yes | Yes | | Beta LLC | Standard | Retail | No | No | | Gamma Inc | Enterprise | Finance | Yes | Yes |
Each column becomes a variable you can use in conditional logic.
Data Hygiene Rules
Conditional logic requires exact matches. These fail:
Best practice: Use data validation in Google Sheets to enforce exact values:
1. Select column
2. Data → Data validation
3. Criteria: List of items
4. Enter allowed values: Basic, Standard, Premium
5. Reject invalid inputs
Now your data is clean and conditionals work reliably.
Step 2: Basic Conditional Syntax
Simple If Statement
Show content only when a condition is true:
`
{{#if Variable Name}}
Content displayed when variable exists or is true
{{/if}}
`
Example: Optional rush delivery notice
`
{{#if Rush Delivery}}
⚡ EXPEDITED TIMELINE
This project includes rush delivery. We will prioritize your work and
deliver 2 weeks ahead of the standard timeline. Additional rush fee of
${{Rush Fee}} applies.
{{/if}}
`
Result:
If-Else Statement
Show different content depending on condition:
`
{{#if Variable}}
Content if true
{{else}}
Content if false
{{/if}}
`
Example: Payment status message
`
PAYMENT STATUS
{{#if Payment Status == "Paid"}} ✓ Payment received. Thank you!
Your account is current. Next invoice due: {{Next Invoice Date}}. {{else}} ⚠ Payment pending
Please complete payment by {{Due Date}} to avoid service interruption.
Pay online: {{Payment Link}}
{{/if}}
`
Result:
One template handles both scenarios.
Comparison Operators
Check specific values with comparison operators:
Equal to:
`
{{#if Service Tier == "Premium"}}Premium content{{/if}}
`
Not equal to:
`
{{#if Region != "US"}}International shipping terms apply.{{/if}}
`
Greater than / Less than:
`
{{#if Order Total > 1000}}
BULK DISCOUNT APPLIED
Your order qualifies for 10% bulk discount.
{{/if}}
{{#if Stock Level <= 5}}
⚠ LOW STOCK ALERT - Only {{Stock Level}} units remaining
{{/if}}
`
Greater/Less than or equal:
`
{{#if Contract Length >= 12}}Annual contract benefits{{/if}}
{{#if Days Overdue <= 30}}Gentle reminder{{else}}Urgent notice{{/if}}
`
Step 3: Multi-Tier Conditionals
Handle multiple exclusive options with if-else chains:
`
{{#if Tier == "Basic"}}
Content for Basic
{{else if Tier == "Standard"}}
Content for Standard
{{else if Tier == "Premium"}}
Content for Premium
{{else if Tier == "Enterprise"}}
Content for Enterprise
{{/if}}
`
Real example: Service tier benefits
`
YOUR BENEFITS
{{#if Service Tier == "Basic"}} BASIC PACKAGE • Email support (48-hour response) • Standard processing times • Monthly reporting • 3 user seats {{/if}}
{{#if Service Tier == "Standard"}} STANDARD PACKAGE • Priority email support (24-hour response) • Phone support (business hours) • Expedited processing • Weekly reporting • 10 user seats • Quarterly account reviews {{/if}}
{{#if Service Tier == "Premium"}} PREMIUM PACKAGE • 24/7 priority support (2-hour response) • Dedicated account manager • Instant processing • Real-time reporting dashboard • Unlimited user seats • Monthly strategy calls • Quarterly business reviews • Annual on-site consultation {{/if}}
{{#if Service Tier == "Enterprise"}} ENTERPRISE PACKAGE Everything in Premium, plus: • Custom integrations • Dedicated support team (not just one person) • White-glove onboarding • Custom SLAs • Volume pricing discounts
Contact {{Sales Rep Name}} for custom enterprise pricing.
{{/if}}
`
Result: Each client sees only their tier benefits. One template = 4 versions.
Step 4: Nested Conditionals
Conditionals inside conditionals for complex logic:
`
{{#if Service Tier == "Premium"}}
{{#if Add-On Selected == "Extra Storage"}}
You've added 1TB extra storage ($50/month)
{{/if}}
{{#if Add-On Selected == "Priority Support"}}
You've added priority phone support ($100/month)
{{/if}}
{{/if}}
`
Use case: Show add-on details only if customer is Premium *and* they selected add-ons.
Real example: Industry-specific compliance
`
COMPLIANCE & SECURITY
{{#if Industry == "Healthcare"}} HIPAA COMPLIANCE
All services are HIPAA-compliant. We will execute a Business Associate Agreement (BAA) prior to project start.
{{#if PHI Handling == "Yes"}} Your project involves Protected Health Information (PHI). Additional security measures: • Encrypted data transmission (TLS 1.3) • Encrypted storage (AES-256) • Access logging and audit trails • Annual third-party security audits {{/if}}
Documentation: {{HIPAA Docs Link}} {{/if}}
{{#if Industry == "Finance"}} FINANCIAL DATA SECURITY
We maintain SOC 2 Type II certification and comply with: • PCI-DSS (for payment card data) • GLBA (Gramm-Leach-Bliley Act) • State-specific financial privacy regulations
{{#if PCI Scope == "In Scope"}} Your project involves payment card data. We will: • Process data in PCI-compliant environments only • Never store full card numbers • Maintain quarterly PCI compliance reports • Provide attestation of compliance {{/if}}
Security documentation: {{Security Docs Link}} {{/if}}
{{#if Industry == "Retail"}} DATA PROTECTION
We comply with standard e-commerce security practices including SSL encryption and secure payment gateways.
{{/if}}
`
Result: Healthcare clients see HIPAA info, finance clients see SOC 2, retail clients see basic security. All from one template.
Step 5: Multiple Conditions (AND/OR Logic)
Combine multiple conditions:
AND logic (both must be true):
`
{{#if (Premium Member) AND (Active)}}
Content for active premium members only
{{/if}}
`
OR logic (either can be true):
`
{{#if (Region == "US") OR (Region == "Canada")}}
North American shipping: USPS/Canada Post, 5-7 business days
{{/if}}
`
Real example: Discount eligibility
`
PRICING
Subtotal: ${{Subtotal}}
{{#if (Order Total > 5000) AND (Customer Type == "Returning")}} VALUED CUSTOMER DISCOUNT Your order qualifies for: • 15% returning customer discount: -${{Discount Amount}} {{/if}}
{{#if (Order Total > 10000) OR (Contract Length == "Annual")}} BULK/COMMITMENT DISCOUNT • Special pricing applied: -${{Discount Amount}} {{/if}}
Total: ${{Final Total}}
`
Logic:
Step 6: Conditional Formatting
Not just text—conditionals work for formatting too:
Example: Status color coding
`
Status: {{Order Status}}
{{#if Order Status == "Shipped"}} 🟢 Your order is on the way! {{/if}}
{{#if Order Status == "Processing"}} 🟡 Your order is being prepared {{/if}}
{{#if Order Status == "Delayed"}}
🔴 Delay notice: {{Delay Reason}}
{{/if}}
`
Visual indicators improve readability.
Step 7: Combining Conditionals with Loops
Show repeating sections conditionally:
`
{{#if Deliverables}}
PROJECT DELIVERABLES
{{#each Deliverables}}
Use case: Only show "Deliverables" section if deliverables exist. Prevents blank sections.
Advanced example: Tiered line items
`
{{#each Line Items}}
{{@number}}. {{Product Name}} - ${{Unit Price}}
Quantity: {{Quantity}}
{{#if Discount Applicable == "Yes"}}
Discount ({{Discount Percent}}%): -${{Discount Amount}}
{{/if}}
{{#if Quantity >= 10}}
✓ Bulk pricing applied
{{/if}}
Subtotal: ${{Line Total}}
{{/each}}
`
Each line item can have conditional content (discount, bulk notice).
Real-World Template Examples
Example 1: Conditional Contract Clauses
Scenario: Legal contracts with region-specific clauses
`
SERVICE AGREEMENT
...
GOVERNING LAW
{{#if Client State == "California"}}
This Agreement shall be governed by the laws of the State of California.
Any disputes shall be resolved in the courts of {{Client County}}, California.
CALIFORNIA-SPECIFIC PROVISIONS
{{Client Name}} acknowledges receipt of the California Consumer Privacy Act
(CCPA) disclosures attached as Exhibit A.
{{/if}}
{{#if Client State == "New York"}}
This Agreement shall be governed by the laws of the State of New York.
Disputes shall be resolved via binding arbitration in New York, NY.
NEW YORK-SPECIFIC PROVISIONS
This Agreement is subject to New York's choice of law rules.
{{/if}}
{{#if (Client State != "California") AND (Client State != "New York")}}
This Agreement shall be governed by the laws of {{Client State}}.
Disputes shall be resolved in accordance with {{Client State}} law.
{{/if}}
...
`
Result: One contract template, jurisdiction-specific clauses insert automatically.
Example 2: Conditional Proposal Pricing
Scenario: Proposals with tiered pricing and optional add-ons
`
INVESTMENT
{{#if Service Tier == "Basic"}}
Basic Package: $2,500/month
Includes:
• Up to 20 hours/month
• Email support
• Monthly reporting
{{#if Add Website Hosting == "Yes"}}
Add-on: Website Hosting - $50/month
{{/if}}
{{#if Add Extra Hours == "Yes"}}
Add-on: Additional 10 hours - $1,000/month
{{/if}}
{{#if Total Add-Ons > 0}}
Subtotal: $2,500
Add-ons: ${{Add-On Total}}
Total Monthly: ${{Monthly Total}}
{{else}}
Total Monthly: $2,500
{{/if}}
{{/if}}
{{#if Service Tier == "Professional"}}
Professional Package: $5,000/month
Includes:
• Up to 50 hours/month
• Priority email + phone support
• Weekly reporting
• Dedicated account manager
• Hosting included (no add-on fee)
{{#if Add Extra Hours == "Yes"}}
Add-on: Additional 20 hours - $1,500/month
Total Monthly: ${{Monthly Total with Add-Ons}}
{{else}}
Total Monthly: $5,000
{{/if}}
{{/if}}
{{#if Service Tier == "Enterprise"}}
Enterprise Package: Custom Pricing
Includes:
• Unlimited hours
• 24/7 support
• Real-time reporting
• Dedicated team
• All hosting and infrastructure included
• Custom integrations
{{#if Custom Requirements}}
Custom scope: {{Custom Requirements}}
{{/if}}
Investment: ${{Custom Price}}/month
Schedule a call with {{Sales Rep Name}} to finalize enterprise terms.
{{/if}}
{{#if Discount > 0}}
──────────────
SPECIAL OFFER
{{Discount Description}}
Discount: -${{Discount Amount}}
Final Monthly Total: ${{Discounted Total}}
{{/if}}
PAYMENT TERMS
{{#if Payment Terms == "Monthly"}}
Invoiced monthly on the 1st. Auto-pay via credit card or ACH.
{{/if}}
{{#if Payment Terms == "Quarterly"}}
Invoiced quarterly. Save 5% with quarterly billing.
{{/if}}
{{#if Payment Terms == "Annual"}}
Invoiced annually. Save 10% with annual prepayment.
Final annual investment: ${{Annual Total}}
{{/if}}
`
Result: Pricing adapts to tier, add-ons, discounts, and payment terms. One template handles dozens of pricing scenarios.
Example 3: Conditional Employee Onboarding
Scenario: Onboarding packets vary by role and department
`
WELCOME TO {{Company Name}}, {{Employee First Name}}!
We're excited to have you join our team as {{Job Title}} in the {{Department}} department.
YOUR FIRST WEEK
{{#if Department == "Engineering"}}
ENGINEERING ONBOARDING
Monday:
• 9am: Welcome meeting with {{Manager Name}}
• 10am: IT setup - laptop, dev environment, GitHub access
• 2pm: Engineering team intro (meet the team)
Tuesday:
• 9am: Codebase walkthrough with {{Tech Lead Name}}
• 11am: Set up local development environment
• 2pm: First sprint planning meeting
{{#if Role Level == "Senior"}}
Wednesday:
• 9am: Architecture review with CTO
• 2pm: Mentor assignment - you'll mentor {{Junior Dev Name}}
{{/if}}
{{#if Role Level == "Junior"}}
Wednesday:
• 9am: Onboarding buddy assignment - {{Senior Dev Name}} will mentor you
• 2pm: Training: Our development workflow
{{/if}}
{{/if}}
{{#if Department == "Sales"}}
SALES ONBOARDING
Monday:
• 9am: Welcome meeting with {{Manager Name}}
• 10am: CRM training (Salesforce)
• 2pm: Sales team intro
Tuesday:
• 9am: Product training with Product team
• 2pm: Pricing and proposal process
Wednesday:
• 9am: Shadow {{Senior Sales Rep}} on client calls
• 2pm: Territory assignment and quota discussion
{{#if Role Level == "Account Executive"}}
Thursday:
• 9am: Meet your sales engineer: {{SE Name}}
• 2pm: Review your pipeline and first 30-day targets
{{/if}}
{{/if}}
{{#if Department == "Marketing"}}
MARKETING ONBOARDING
Monday:
• 9am: Welcome meeting with {{Manager Name}}
• 10am: Marketing tools setup (HubSpot, analytics platforms)
• 2pm: Marketing team intro
Tuesday:
• 9am: Brand guidelines and messaging training
• 2pm: Current campaigns overview
{{#if Role == "Content Writer"}}
Wednesday:
• 9am: Content calendar review
• 11am: SEO training
• 2pm: Meet your editor: {{Editor Name}}
{{/if}}
{{#if Role == "Designer"}}
Wednesday:
• 9am: Design system walkthrough
• 11am: Figma setup and access
• 2pm: First design project assignment
{{/if}}
{{/if}}
BENEFITS
{{#if Employment Type == "Full-Time"}}
FULL-TIME BENEFITS
• Health insurance: Effective {{Benefits Start Date}}
• 401(k): Eligible after {{401k Eligibility Days}} days, company match up to {{Match Percent}}%
• PTO: {{PTO Days}} days/year, accrues monthly
• Sick leave: {{Sick Days}} days/year
{{#if Role Level == "Senior" OR Role Level == "Manager"}}
• Stock options: {{Stock Option Shares}} shares, vesting over {{Vesting Years}} years
{{/if}}
{{/if}}
{{#if Employment Type == "Contractor"}}
CONTRACTOR TERMS
• Hourly rate: ${{Hourly Rate}}/hour
• Benefits: Not applicable (contractor status)
• Payment: Invoiced {{Invoice Frequency}}
{{/if}}
NEXT STEPS
☐ Complete HR paperwork by {{HR Deadline}}
☐ Set up direct deposit
☐ Schedule 1:1 with {{Manager Name}}
{{#if Equipment Needed}}
☐ Pick up your equipment: {{Equipment List}}
{{/if}}
{{#if Parking Pass}}
☐ Get parking pass from reception
{{/if}}
Questions? Contact:
• Your manager: {{Manager Email}}
• HR: hr@company.com
• IT: it@company.com
Welcome aboard! We're glad you're here.
`
Result: Onboarding content adapts to department, role level, employment type, and individual circumstances. One template for entire company.
Common Conditional Template Mistakes
Mistake 1: Case Sensitivity Errors
Problem:
`
{{#if Service Tier == "premium"}}
`
But data says "Premium" (capital P). Condition never matches.
Fix: Match case exactly, or normalize data (always use Title Case or UPPERCASE in your spreadsheet).
Mistake 2: Trailing Spaces
Problem:
`
{{#if Region == "US"}}
`
But data has "US " (space after). No match.
Fix: Clean data with
TRIM() function in Google Sheets, or use data validation to prevent spaces.
Mistake 3: Forgetting
/if Close Tag
Problem:
`
{{#if Premium}}
Premium content here
// Forgot {{/if}}
`
Result: Everything after the
{{#if}} gets treated as conditional. Rest of document disappears or shows incorrectly.
Fix: Always close tags. Use an editor with syntax highlighting to catch missing closes.
Mistake 4: Complex Nested Logic Gets Unreadable
Problem:
`
{{#if A}}
{{#if B}}
{{#if C}}
{{#if D}}
Content buried four levels deep
{{/if}}
{{/if}}
{{/if}}
{{/if}}
`
Result: Hard to debug, hard to maintain, easy to break.
Fix: Restructure logic. Combine conditions:
`
{{#if (A) AND (B) AND (C) AND (D)}}
Content
{{/if}}
`
Or split into multiple simpler conditionals.
Mistake 5: Testing in Production
Problem: Build complex conditional template, generate 100 documents, realize logic is wrong. Now you have 100 wrong documents.
Fix: Always test with 2-3 rows of data covering different scenarios:
Test row for "Basic" tier
Test row for "Premium" tier
Test row for edge cases (empty fields, etc.)
Generate test documents. Review carefully. Only then batch-generate for real.
Advanced: Conditional Tables
Google Docs tables can have conditional rows:
`
| Item | Quantity | Price |
|------|----------|-------|
{{#each Line Items}}
| {{Item Name}} | {{Qty}} | ${{Price}} |
{{#if Discount Applies}}
| *Discount* | | -${{Discount}} |
{{/if}}
{{/each}}
| Total | | ${{Total}} |
`
Result: Discount row only appears for discounted items.
Advanced: Conditional Images/Logos
Show different logos based on conditions:
`
{{#if Brand == "Primary"}}
[Insert Primary Brand Logo]
{{/if}}
{{#if Brand == "Sub-Brand A"}}
[Insert Sub-Brand A Logo]
{{/if}}
`
Use case: Multi-brand companies with one template system.
Tools for Building Conditional Templates
Doc Variables (Recommended)
- Syntax:
{{#if Variable}}...{{/if}}
Supports: Nested conditionals, AND/OR logic, loops, comparisons
UI: Sidebar in Google Docs for testing and preview
Best for: Non-technical users, complex logic
Google Apps Script (Custom)
Write your own conditional logic in JavaScript:
`javascript
body.replaceText('{{Premium Content}}',
(tier === 'Premium') ? 'Premium benefits here' : ''
);
``
Best for: Developers, ultra-custom needs
Zapier/Make + Template Tool
Use automation to set variables that trigger conditionals:
Example: HubSpot deal tier → Google Sheet → conditional template generation
Testing Conditional Templates Checklist
Before going live:
☐ Test each branch: If you have 3 tiers, generate a document for each tier ☐ Test edge cases: What if a field is empty? What if tier is misspelled? ☐ Check nested logic: Each nested conditional works independently ☐ Verify formatting: Conditionals don't break page layout ☐ Review spacing: Removing sections shouldn't leave awkward gaps ☐ Test combinations: Premium + rush delivery + international = does logic work?
Generate test documents, inspect carefully, iterate until perfect.
Maintenance: Keeping Conditional Templates Updated
Version Control
When updating conditional templates:
1. Document changes: "v2.0 - Added Enterprise tier conditional" 2. Test before deploying: Don't push changes without testing 3. Keep old versions: File → Version history → Name version 4. Communicate: Tell team when template logic changes
When to Split Templates
Conditionals aren't always the answer. Split templates when:
- Logic gets too complex (>5 nested levels)
Rule of thumb: If you can't explain the conditional logic in 2 minutes, consider separate templates.
Real-World Time Savings
Marketing agency with 3 service tiers
Before conditional templates:
After conditional templates:
Savings: 28 minutes per proposal × 50 proposals/month = 23 hours/month saved
At $100/hour = $2,300/month in labor savings
Plus: Zero pricing errors, consistent branding, easier onboarding for new sales team members.
Getting Started: 7-Day Implementation
Day 1: Audit Your Templates
Day 2: Plan Your Conditional Logic
Day 3: Build Your First Conditional Template
Day 4: Add Complexity
Day 5: Test Edge Cases
Day 6: Team Training
Day 7: Go Live
Week 2+: Convert next template. Build library of conditional templates.
Final Thoughts
Conditional templates transform static documents into smart systems. One well-built conditional template replaces 5-20 static versions, saving hours of maintenance and eliminating version control chaos.
The upfront investment—learning conditional syntax, planning logic, testing—pays back quickly. After your first conditional template works, the next five are easy.
Start with one template. Pick something you generate frequently with 2-3 variations. Build the conditional logic. Test it thoroughly. Then watch as one template handles scenarios that used to require multiple files.
Your future self (and your team) will thank you.
---
*Doc Variables makes conditional Google Docs templates simple. Use if/then logic, nested conditions, and loops to build smart templates that adapt to your data—no coding required. Try it free with 20 document generations at docvars.com.*
Ready to try Doc Variables?
Join 190,000+ users creating amazing Google Doc templates.
Install Now - It's Free