G
G
M
M
Advanced Email 模板
使用Liquid Language实现动态和个性化电子邮件
Advanced Email 模板
Advanced Email 模板
Advanced Email 模板
高级电子邮件模板化允许高度自定义的电子邮件模板。它可以用于拖放编辑器和直接导入的HTML。
Bird电子邮件模板语言文档
Bird电子邮件模板语言是一种强大的工具,基于Shopify的Liquid语法,具有专门为电子邮件营销设计的自定义扩展。该语言允许您高效地创建动态、个性化的电子邮件模板,使您能够向订阅者发送有针对性的内容。
Bird电子邮件模板语言的主要功能包括:
使用预定义变量轻松实现个性化
根据订阅者属性或分段条件显示内容
与您的产品目录和外部数据源集成
通过翻译支持国际化
使用过滤器的高级格式选项
本指南将引导您了解该语言的基本组成部分,提供示例和最佳实践,以帮助您创建有效的电子邮件模板。有关基础Liquid语法的全面参考,请参阅Shopify Liquid 文档。
Predefined Variables
预定义变量允许您轻松个性化您的电子邮件,使用收件人信息和组织详细信息。
联系人变量
使用这些变量在您的电子邮件中插入特定收件人的信息:
{{ contact.attributes.firstName }}
{{ contact.attributes.lastName }}
{{ contact.attributes.email }}
您也可以使用您为联系人定义的任何自定义属性。
组织变量
在所有电子邮件中始终如一地包括您的公司信息:
{{ organization.name }}
{{ organization.fullAddress }}
{{ organization.websiteUrl }}
{{ organization.street }}
{{ organization.city }}
{{ organization.state }}
{{ organization.country }}
{{ organization.zipCode }}
电子邮件地址变量
直接引用收件人的电子邮件地址:
{{ emailAddress }}
最佳实践:总是为个性化变量设置一个后备选项,以防止它们未被设置在特定收件人中。
标签过滤器
过滤器允许您修改变量的输出,确保内容的格式正确无误,以适用于您的电子邮件。
default
:如果变量为空,则设置一个后备值
{{ contact.attributes.firstName | default: 'Valued Customer' }}
capitalize
,upcase
,downcase
:更改文本的大小写
{{ contact.attributes.firstName | capitalize }}
{{ product.brand | upcase }}
{{ 'IMPORTANT NOTICE' | downcase }}
date
:根据指定的模式格式化日期
{{ contact.attributes.birthday | date: '%B %d, %Y' }}
{{ 'now' | date: '%Y-%m-%d %H:%M' }}
currencyFormat
:将数字格式化为货币
{{ product.price | currencyFormat: 'USD' }}
最佳实践:使用currencyFormat
过滤器进行所有价格的显示,确保在不同地区之间的一致性和正确格式。
特殊标签
特殊标签提供快速访问常见电子邮件营销需求,例如取消订阅链接和网页浏览。
取消订阅链接
遵循电子邮件法规合规的必要条件:
{% unsubscribe %} <!-- Outputs: <a href="...">Unsubscribe</a> -->
{% unsubscribe 'Click here to unsubscribe' %} <!-- Custom text -->
<a href="{% unsubscribeLink %}">Manage your preferences</a> <
网页浏览链接
提供一个在网络浏览器中查看电子邮件的选项:
{% webView %} <!-- Outputs: <a href="...">View in browser</a> -->
{% webView 'View this email online' %} <!-- Custom text -->
<a href="{% webViewLink %}">Trouble viewing? Click here</a> <
日期标签
用于在您的电子邮件中显示当前日期:
Today's Date: {% currentYear %}-{% currentMonthName %}-{% currentDay %}
Sent on: {% currentWeekday %}
最佳实践:在您的电子邮件中始终包括一个取消订阅链接,通常在页脚中。
预定义变量允许您轻松个性化您的电子邮件,使用收件人信息和组织详细信息。
联系人变量
使用这些变量在您的电子邮件中插入特定收件人的信息:
{{ contact.attributes.firstName }}
{{ contact.attributes.lastName }}
{{ contact.attributes.email }}
您也可以使用您为联系人定义的任何自定义属性。
组织变量
在所有电子邮件中始终如一地包括您的公司信息:
{{ organization.name }}
{{ organization.fullAddress }}
{{ organization.websiteUrl }}
{{ organization.street }}
{{ organization.city }}
{{ organization.state }}
{{ organization.country }}
{{ organization.zipCode }}
电子邮件地址变量
直接引用收件人的电子邮件地址:
{{ emailAddress }}
最佳实践:总是为个性化变量设置一个后备选项,以防止它们未被设置在特定收件人中。
标签过滤器
过滤器允许您修改变量的输出,确保内容的格式正确无误,以适用于您的电子邮件。
default
:如果变量为空,则设置一个后备值
{{ contact.attributes.firstName | default: 'Valued Customer' }}
capitalize
,upcase
,downcase
:更改文本的大小写
{{ contact.attributes.firstName | capitalize }}
{{ product.brand | upcase }}
{{ 'IMPORTANT NOTICE' | downcase }}
date
:根据指定的模式格式化日期
{{ contact.attributes.birthday | date: '%B %d, %Y' }}
{{ 'now' | date: '%Y-%m-%d %H:%M' }}
currencyFormat
:将数字格式化为货币
{{ product.price | currencyFormat: 'USD' }}
最佳实践:使用currencyFormat
过滤器进行所有价格的显示,确保在不同地区之间的一致性和正确格式。
特殊标签
特殊标签提供快速访问常见电子邮件营销需求,例如取消订阅链接和网页浏览。
取消订阅链接
遵循电子邮件法规合规的必要条件:
{% unsubscribe %} <!-- Outputs: <a href="...">Unsubscribe</a> -->
{% unsubscribe 'Click here to unsubscribe' %} <!-- Custom text -->
<a href="{% unsubscribeLink %}">Manage your preferences</a> <
网页浏览链接
提供一个在网络浏览器中查看电子邮件的选项:
{% webView %} <!-- Outputs: <a href="...">View in browser</a> -->
{% webView 'View this email online' %} <!-- Custom text -->
<a href="{% webViewLink %}">Trouble viewing? Click here</a> <
日期标签
用于在您的电子邮件中显示当前日期:
Today's Date: {% currentYear %}-{% currentMonthName %}-{% currentDay %}
Sent on: {% currentWeekday %}
最佳实践:在您的电子邮件中始终包括一个取消订阅链接,通常在页脚中。
预定义变量允许您轻松个性化您的电子邮件,使用收件人信息和组织详细信息。
联系人变量
使用这些变量在您的电子邮件中插入特定收件人的信息:
{{ contact.attributes.firstName }}
{{ contact.attributes.lastName }}
{{ contact.attributes.email }}
您也可以使用您为联系人定义的任何自定义属性。
组织变量
在所有电子邮件中始终如一地包括您的公司信息:
{{ organization.name }}
{{ organization.fullAddress }}
{{ organization.websiteUrl }}
{{ organization.street }}
{{ organization.city }}
{{ organization.state }}
{{ organization.country }}
{{ organization.zipCode }}
电子邮件地址变量
直接引用收件人的电子邮件地址:
{{ emailAddress }}
最佳实践:总是为个性化变量设置一个后备选项,以防止它们未被设置在特定收件人中。
标签过滤器
过滤器允许您修改变量的输出,确保内容的格式正确无误,以适用于您的电子邮件。
default
:如果变量为空,则设置一个后备值
{{ contact.attributes.firstName | default: 'Valued Customer' }}
capitalize
,upcase
,downcase
:更改文本的大小写
{{ contact.attributes.firstName | capitalize }}
{{ product.brand | upcase }}
{{ 'IMPORTANT NOTICE' | downcase }}
date
:根据指定的模式格式化日期
{{ contact.attributes.birthday | date: '%B %d, %Y' }}
{{ 'now' | date: '%Y-%m-%d %H:%M' }}
currencyFormat
:将数字格式化为货币
{{ product.price | currencyFormat: 'USD' }}
最佳实践:使用currencyFormat
过滤器进行所有价格的显示,确保在不同地区之间的一致性和正确格式。
特殊标签
特殊标签提供快速访问常见电子邮件营销需求,例如取消订阅链接和网页浏览。
取消订阅链接
遵循电子邮件法规合规的必要条件:
{% unsubscribe %} <!-- Outputs: <a href="...">Unsubscribe</a> -->
{% unsubscribe 'Click here to unsubscribe' %} <!-- Custom text -->
<a href="{% unsubscribeLink %}">Manage your preferences</a> <
网页浏览链接
提供一个在网络浏览器中查看电子邮件的选项:
{% webView %} <!-- Outputs: <a href="...">View in browser</a> -->
{% webView 'View this email online' %} <!-- Custom text -->
<a href="{% webViewLink %}">Trouble viewing? Click here</a> <
日期标签
用于在您的电子邮件中显示当前日期:
Today's Date: {% currentYear %}-{% currentMonthName %}-{% currentDay %}
Sent on: {% currentWeekday %}
最佳实践:在您的电子邮件中始终包括一个取消订阅链接,通常在页脚中。
条件逻辑和循环
条件逻辑和循环允许您创建动态内容,以适应每个接收者的属性或偏好。
If Statements
使用if语句根据接收者属性显示不同内容:
{% 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
将内容定位到特定的受众群体:
{% if contact.segments contains "abcd-1234-efgh-5678" }
This contact is a member of the segment with ID "abcd-1234-efgh-5678".
{% endif %}
Loops
遍历数据数组以创建动态列表:
<h3>Your Favorite Colors:</h3>
<ul>
{% for color in contact.attributes.favoriteColors %}
<li style="color: {{ color }};">{{ color }}</li>
{% endfor %}
<
最佳实践:使用条件逻辑来针对不同的受众群体定制您的信息,提高相关性和参与度。
与 Products 合作
将您的产品目录直接集成到您的电子邮件模板中,以展示动态产品。
单一产品查询
显示特定产品的详细信息:
{% 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>
{
产品源
从源中展示多个产品:
<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>
最佳实践:使用产品源创建动态内容,如电子邮件中的“推荐产品”或“新品上架”部分。
Events
利用事件数据创建基于订阅者操作的高度相关、及时的电子邮件。这通常与通过包含事件触发器的旅程发送的电子邮件相关。
{% 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>
{
最佳实践:使用事件数据触发及时、相关的电子邮件,例如未结账购物车提醒或购买确认。
折扣 Codes
在您的电子邮件中生成和显示独特的折扣代码以激励购买。
<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>
最佳实践:使用独特的折扣代码来跟踪不同电子邮件活动或细分市场的表现。
Translations
使用翻译功能创建多语言电子邮件模板。
首先,设置您的翻译文件(JSON格式)以支持的每种语言。例如:
{
"welcome_message": "Welcome to our store!",
"sale_announcement": "Don't miss our big sale, {{name}}!",
"product_of_the_day": "Product of the day: {{product}}"
}
然后在您的模板中使用t
过滤器:
<h1>{{ "welcome_message" | t }}</h1>
<p>{{ "sale_announcement" | t: "name", contact.attributes.firstName }}</p>
<h2>{{ "product_of_the_day" | t: "product", featuredProduct.title }}</h2>
最佳做法:使用翻译创建一个可用于多种语言的单一模板,减少维护工作量。
外部 Data Sources
将实时数据从外部来源集成到您的电子邮件中。您可以在这里了解更多关于外部数据来源的信息。
Basic Usage:
{% datafetch "weather-api" %}
<p>Current temperature in your area: {{ dataFetchResponse.temperature }}°C</p>
<p>Weather condition: {{ dataFetchResponse.condition }}</p>
{
使用动态URL
对于需要动态参数的API:
{% 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>
{
最佳实践:使用外部数据源在电子邮件中包含最新的、个性化的信息,例如账户余额、忠诚积分或个性化推荐。
Advanced Liquid Syntax
虽然 Bird Email Template Language 提供了针对电子邮件营销的强大功能,但它是基于 Liquid 构建的,Liquid 提供了更多高级功能。以下是一些例子:
数组和对象处理
{% assign sorted_products = products | sort: 'price' %}
{% assign expensive_products = sorted_products | where: "price", ">", 100 %}
数学运算
{% assign total = product.price | times: item.quantity %}
{% assign discount = total | divided_by: 4 %}
字符串操作
{% assign lowercase_name = contact.attributes.firstName | downcase %}
{% assign greeting = "Hello, " | append: lowercase_name | capitalize %}
控制流
{% 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 %}
关于这些高级 Liquid 功能的全面指南,请参考Shopify Liquid 文档。
最佳实践:虽然这些高级功能很强大,但要谨慎使用。过于复杂的模板可能难以维护,并可能影响电子邮件的渲染性能。
请记住在不同的电子邮件客户端中彻底测试您的电子邮件模板,以确保一致的渲染和最佳性能。Bird 平台提供的工具可用于在发送之前预览和测试您的模板。
通过掌握 Bird Email Template Language,您将能够创建高度动态、个性化和吸引人的电子邮件活动,以与您的受众产生共鸣并推动结果。