Advanced Email Templating

Advance Email Templating allows for highly customized email templates. It can be used in both the drag-and-drop editor and directly on imported HTML.

Bird Email Template Language Documentation

Introduction

The Bird Email Template Language is a powerful tool based on Shopify's Liquid syntax, with custom extensions designed specifically for email marketing. This language allows you to create dynamic, personalized email templates efficiently, enabling you to deliver targeted content to your subscribers.

Key features of the Bird Email Template Language include:

  • Easy personalization using predefined variables

  • Conditional content display based on subscriber attributes or segments

  • Integration with your product catalog and external data sources

  • Support for internationalization through translations

  • Advanced formatting options with filters

This guide will walk you through the essential components of the language, providing examples and best practices to help you create effective email templates.

For a comprehensive reference on the underlying Liquid syntax, please refer to the Shopify Liquid documentation.

Predefined Variables

Predefined variables allow you to easily personalize your emails with recipient information and organization details.

Contact Variables

Use these to insert recipient-specific information into your emails:

{{ contact.attributes.firstName }}
{{ contact.attributes.lastName }}
{{ contact.attributes.email }}

You can also use any custom attributes that you've defined for your contacts.

Organization Variables

Include your company information consistently across all emails:

{{ organization.name }}
{{ organization.fullAddress }}
{{ organization.websiteUrl }}
{{ organization.street }}
{{ organization.city }}
{{ organization.state }}
{{ organization.country }}
{{ organization.zipCode }}

Email Address Variable

Reference the recipient's email address directly:

{{ emailAddress }}

Best Practice: Always have a fallback for personalization variables in case they're not set for a particular recipient.

Tag Filters

Filters allow you to modify the output of your variables, ensuring that the content is formatted correctly for your emails.

  • default: Set a fallback value if the variable is empty

{{ contact.attributes.firstName | default: 'Valued Customer' }}
  • capitalize, upcase, downcase: Change text case

{{ contact.attributes.firstName | capitalize }}
{{ product.brand | upcase }}
{{ 'IMPORTANT NOTICE' | downcase }}
  • date: Format dates according to specified patterns

{{ contact.attributes.birthday | date: '%B %d, %Y' }}
{{ 'now' | date: '%Y-%m-%d %H:%M' }}
  • currencyFormat: Format numbers as currency

{{ product.price | currencyFormat: 'USD' }}

Best Practice: Use the currencyFormat filter for all price displays to ensure consistency and proper formatting across different regions.

Special Tags

Special tags provide quick access to common email marketing requirements, such as unsubscribe links and web views.

Essential for compliance with email regulations:

{% unsubscribe %}  <!-- Outputs: <a href="...">Unsubscribe</a> -->
{% unsubscribe 'Click here to unsubscribe' %}  <!-- Custom text -->
<a href="{% unsubscribeLink %}">Manage your preferences</a>  <!-- Custom HTML -->

Provide an option to view the email in a web browser:

{% webView %}  <!-- Outputs: <a href="...">View in browser</a> -->
{% webView 'View this email online' %}  <!-- Custom text -->
<a href="{% webViewLink %}">Trouble viewing? Click here</a>  <!-- Custom HTML -->

Date Tags

Useful for displaying current dates in your emails:

Today's Date: {% currentYear %}-{% currentMonthName %}-{% currentDay %}
Sent on: {% currentWeekday %}

Best Practice: Always include an unsubscribe link in your emails, typically in the footer.

Conditional Logic and Loops

Conditional logic and loops allow you to create dynamic content that adapts to each recipient's attributes or preferences.

If Statements

Use if statements to show different content based on recipient attributes:

{% if contact.attributes.membership == "gold" %}
  <h2>Exclusive Gold Member Offer</h2>
  <p>Enjoy 20% off your next purchase!</p>
{% elsif contact.attributes.membership == "silver" %}
  <h2>Special Silver Member Discount</h2>
  <p>Get 15% off select items!</p>
{% else %}
  <h2>Limited Time Offer</h2>
  <p>Save 10% on your next order!</p>
{% endif %}

Checking Segment Membership

Target content to specific segments of your audience:

{% if contact.segments contains "abcd-1234-efgh-5678" }
  This contact is a member of the segment with ID "abcd-1234-efgh-5678".
{% endif %}

Loops

Iterate over arrays of data to create dynamic lists:

<h3>Your Favorite Colors:</h3>
<ul>
{% for color in contact.attributes.favoriteColors %}
  <li style="color: {{ color }};">{{ color }}</li>
{% endfor %}
</ul>

Best Practice: Use conditional logic to tailor your message to different audience segments, increasing relevance and engagement.

Working with Products

Integrate your product catalog directly into your email templates for dynamic product displays.

Single Product Lookup

Display details of a specific product:

{% catalog 'PRODUCT-ID-123' %}
  <div class="product">
    <h2>{{ catalogItem.title }}</h2>
    <img src="{{ catalogItem.imageUrl }}" alt="{{ catalogItem.title }}">
    <p>Price: {{ catalogItem.price | currencyFormat: catalogItem.currency }}</p>
    {% if catalogItem.originalPrice > catalogItem.price %}
      <p>Original Price: <strike>{{ catalogItem.originalPrice | currencyFormat: catalogItem.currency }}</strike></p>
    {% endif %}
    <a href="{{ catalogItem.url }}">Shop Now</a>
  </div>
{% endcatalog %}

Product Feed

Display multiple products from a feed:

<h2>Recommended for You</h2>
<div class="product-grid">
  {% productfeed 'FEED-ID-456' %}
    {% for item in catalogItems limit:3 %}
      <div class="product">
        <h3>{{ item.title }}</h3>
        <img src="{{ item.imageUrl }}" alt="{{ item.title }}">
        <p>{{ item.price | currencyFormat: item.currency }}</p>
        <a href="{{ item.url }}">View Product</a>
      </div>
    {% endfor %}
  {% endproductfeed %}
</div>

Best Practice: Use product feeds to create dynamic content like "Recommended Products" or "New Arrivals" sections in your emails.

Events

Leverage event data to create highly relevant, timely emails based on subscriber actions.

{% if event.type == "abandoned_cart" %}
  <h2>Did you forget something?</h2>
  <p>We noticed you left some items in your cart:</p>
  <ul>
  {% for item in event.properties.items %}
    <li>{{ item.product_name }} - {{ item.price | currencyFormat: event.properties.currency }}</li>
  {% endfor %}
  </ul>
  <a href="{{ event.properties.checkout_url }}">Complete your purchase</a>
{% elsif event.type == "purchase_confirmation" %}
  <h2>Thank you for your purchase!</h2>
  <p>Order Total: {{ event.properties.total_price | currencyFormat: event.properties.currency }}</p>
  <p>Order ID: {{ event.properties.order_id }}</p>
{% endif %}

Best Practice: Use event data to trigger timely, relevant emails such as abandoned cart reminders or purchase confirmations.

Discount Codes

Generate and display unique discount codes in your emails to incentivize purchases.

<h2>Your Exclusive Offer</h2>
<p>Use this code for 15% off your next purchase:</p>
<div class="discount-code">{% discountCode "SUMMER_SALE_POOL" %}</div>

Best Practice: Use unique discount codes to track the performance of different email campaigns or segments.

Translations

Create multilingual email templates using the translation feature.

First, set up your translation files (in JSON format) for each language you support. For example:

{
  "welcome_message": "Welcome to our store!",
  "sale_announcement": "Don't miss our big sale, {{name}}!",
  "product_of_the_day": "Product of the day: {{product}}"
}

Then use the t filter in your templates:

<h1>{{ "welcome_message" | t }}</h1>
<p>{{ "sale_announcement" | t: "name", contact.attributes.firstName }}</p>
<h2>{{ "product_of_the_day" | t: "product", featuredProduct.title }}</h2>

Best Practice: Use translations to create a single template that can be used for multiple languages, reducing maintenance overhead.

External Data Sources

Integrate real-time data from external sources into your emails.

Basic Usage

{% datafetch "weather-api" %}
  <p>Current temperature in your area: {{ dataFetchResponse.temperature }}°C</p>
  <p>Weather condition: {{ dataFetchResponse.condition }}</p>
{% enddatafetch %}

Using Dynamic URLs

For APIs that require dynamic parameters:

{% datafetch "user-recommendations", "userId", contact.attributes.userId %}
  <h2>Recommended for You</h2>
  <ul>
  {% for product in dataFetchResponse.recommendations %}
    <li>{{ product.name }} - {{ product.price | currencyFormat: 'USD' }}</li>
  {% endfor %}
  </ul>
{% enddatafetch %}

Best Practice: Use external data sources to include up-to-date, personalized information in your emails, such as account balances, loyalty points, or personalized recommendations.

Advanced Liquid Syntax

While the Bird Email Template Language provides powerful features specific to email marketing, it's built on top of Liquid, which offers additional advanced features. Here are some examples:

Array and Object Handling

{% assign sorted_products = products | sort: 'price' %}
{% assign expensive_products = sorted_products | where: "price", ">", 100 %}

Mathematical Operations

{% assign total = product.price | times: item.quantity %}
{% assign discount = total | divided_by: 4 %}

String Manipulation

{% assign lowercase_name = contact.attributes.firstName | downcase %}
{% assign greeting = "Hello, " | append: lowercase_name | capitalize %}

Control Flow

{% case shipping_method %}
  {% when 'ground' %}
    Estimated delivery: 5-7 business days
  {% when 'express' %}
    Estimated delivery: 2-3 business days
  {% else %}
    Please contact us for shipping information
{% endcase %}

For a comprehensive guide on these advanced Liquid features, please refer to the Shopify Liquid documentation.

Best Practice: While these advanced features are powerful, use them judiciously. Overly complex templates can be difficult to maintain and may impact email rendering performance.

Remember to thoroughly test your email templates across different email clients to ensure consistent rendering and optimal performance. The Bird platform provides tools for previewing and testing your templates before sending.

By mastering the Bird Email Template Language, you'll be able to create highly dynamic, personalized, and engaging email campaigns that resonate with your audience and drive results.

Last updated

#490: Add Entra ID SCIM settings

Change request updated