Liquid Use Cases

Prev Next

Liquid tags allow you to create dynamic, personalized messages across almost all messaging channels, including email, push notifications, SMS, in-app messages, and more. By pulling user attributes into your templates and applying logic, calculations, and formatting, Liquid helps every message adapt in real time to the individual receiving it. This page provides a comprehensive reference to common Liquid use cases with practical examples, helping you build smarter, more relevant communications.

Anniversaries and special dates

Celebrate user milestones or avoid sending messages on holidays.

Anniversary

{% assign signup_years = 'now' | date: "%Y" | minus: user.signup_date | date: "%Y" %}
{% if signup_years > 0 %}
Happy {{ signup_years }} year anniversary!
{% endif %}

Birthday

{% assign birth_month = user.date_of_birth | date: "%m" %}
{% assign current_month = 'now' | date: "%m" %}
{% if birth_month == current_month %}
Happy Birthday! 🎉
{% endif %}

App usage and engagement

Tailor messages based on recent app activity.

Inactivity reminder

{% assign days_since_last_login = 'now' | date: "%s" | minus: user.last_login | date: "%s" | divided_by: 86400 %}
{% if days_since_last_login > 7 %}
We miss you! Check out what’s new.
{% endif %}

Future event reminder

{% assign event_date = '2025-12-01' | date: "%s" %}
{% assign now = 'now' | date: "%s" %}
{% assign days_until_event = (event_date | minus: now) | divided_by: 86400 %}
{{ days_until_event }} days left until our event!

Conditional logic

Show content based on user attributes or behavior.

{% if user.subscription_status == 'active' %}
Thank you for being a subscriber!
{% else %}
Subscribe now to get exclusive benefits.
{% endif %}

Loops

Display multiple items or iterate through lists.

{% for item in user.favorite_products %}
- {{ item.name }}: ${{ item.price }}
{% endfor %}

Date and time calculations

Manipulate dates for reminders, countdowns, or scheduling.

Add duration to date

{{ 'now' | date:"%s" | plus: 259200 | date:"%Y-%m-%d" }}

Countdown to events

{% assign event_timestamp = '2025-12-31' | date: "%s" %}
{% assign now_timestamp = 'now' | date: "%s" %}
{% assign days_left = (event_timestamp | minus: now_timestamp) | divided_by: 86400 %}
{{ days_left }} days remaining!

Numeric calculations and formatting

Perform math or format numbers dynamically.

Simple calculation

{{ 15 | divided_by: 2.0 }} → 7.5

Fallback values

{{ user.points | default: 0 }}

Catalog and content selection

Pull items from a catalog and personalize product recommendations.

{% catalog_items Products 1234 %}
Check out {{ items[0].title }} for just ${{ items[0].price }}!

Language and locale

Adjust messages based on a user’s language or location.

{% if user.language == 'es' %}
¡Hola! Descubre nuestras ofertas.
{% else %}
Hello! Check out our offers.
{% endif %}

Platform and device targeting

Customize messages for OS, device, or carrier.

{% if user.device_os == 'iOS' %}
Open our iOS app to get your offer!
{% elsif user.device_os == 'Android' %}
Open our Android app to get your offer!
{% endif %}

Advanced patterns

Handle arrays, strings, and complex conditions.

Check if array contains value

{% if user.interests contains 'cycling' %}
Explore our new cycling gear!
{% endif %}

String manipulation

{{ user.full_name | split: ' ' | first }} → first name

Best Practices

While creating your messages with liquid tags, ensure you follow these best practices.

  • Always test your Liquid templates to ensure logic works across channels.

  • Use fallback values to prevent empty content.

  • Leverage reusable blocks for repeated patterns.

  • Keep Liquid syntax human-readable for easy maintenance.