This page shows advanced Liquid patterns you can use in Blueshift. You'll find examples for Blueshift's custom filters, external fetch, and best practices for building safe URLs without nested Liquid expressions.
Blueshift adds custom Liquid filters on top of standard Liquid. This page shows how to use money, time_zone, md5, regex_replace, url_encode, strip_html, and numeric helpers like round, ceil, and floor.
Each example uses a single filter at a time, so you can test and reuse them safely.
All examples are verified for Blueshift's Liquid syntax and supported filters.
On this page
- money filter
- time_zone filter
- md5 filter
- regex_replace filter
- url_encode filter
- strip_html filter
- round / ceil / floor
- External fetch example
- Best practices for URL assignment
- Avoiding nested Liquid expressions
money filter
Format numeric amounts according to your account's default currency and format.
Liquid:
Amount: {{ bsft_event_context.amount | money }}
Example data:
{
"bsft_event_context": { "amount": 120 }
}
time_zone filter
Convert timestamps to a specific time zone before formatting with date.
Liquid:
Local time:
{{ bsft_event_context.timestamp
| time_zone: "America/New_York"
| date: "%B %e, %Y %l:%M %p" }}
Example data:
{
"bsft_event_context": {
"timestamp": "2025-08-20T14:30:00Z"
}
}
md5 filter
Hash values (often emails) for integrations that require MD5 hashes.
Liquid:
Hashed email: {{ user.email | md5 }}
Example data:
{
"user": { "email": "alex@example.com" }
}
regex_replace filter
Use regex_replace to remove or replace patterns using a regular expression.
Liquid:
Cleaned subject:
{{ campaign.subject | regex_replace: "[!?.]", "" }}
Example data:
{
"campaign": { "subject": "Welcome back! Ready to shop?" }
}
url_encode filter
Encode query parameters so they are safe to place in URLs.
Liquid:
{% assign search_term = "wireless headphones & speakers" %}
{% assign encoded = search_term | url_encode %}
Search link:
<a href="https://example.com/search?q={{ encoded }}">View results</a>
Example data:
{}
Search link:
https://example.com/search?q=wireless+headphones+%26+speakers
strip_html filter
Remove HTML tags from user-generated or rich-text content.
Liquid:
Plain text:
{{ content_html | strip_html }}
Example data:
{
"content_html": "<p><strong>Hi Alex</strong>, welcome back to our store.</p>"
}
round / ceil / floor
Normalize numeric values for display or eligibility checks.
Liquid:
{% assign raw_score = 4.27 %}
Rounded: {{ raw_score | round }}
Ceiling: {{ raw_score | ceil }}
Floor: {{ raw_score | floor }}
Example data:
{}
Rounded: 4
Ceiling: 5
Floor: 4
External fetch example
Use external_fetch to pull data from an external template configured in Blueshift (for example, pricing, offers, or content blocks).
Note: external_fetch must be set up in your Blueshift account before it is available in Liquid.
Liquid:
{% if external_fetch.shipping_offer
and external_fetch.shipping_offer.message %}
{{ external_fetch.shipping_offer.message }}
{% endif %}
Example data:
{
"external_fetch": {
"shipping_offer": {
"message": "Good news: you qualify for free shipping on your next order."
}
}
}
Best practices for URL assignment
Build URLs in an assign statement first, then use the assigned variable inside attributes like href.
This keeps templates readable and reduces the risk of broken Liquid when you add more filters or URL parameters.
Liquid:
{% assign discount_code = "WELCOME10" %}
{% assign safe_url = item.url
| append: "?code="
| append: discount_code %}
<a href="{{ safe_url }}">Shop now</a>
Example data:
{
"item": {
"title": "Running Shoes",
"url": "https://example.com/running-shoes"
}
}
<a href="https://example.com/running-shoes?code=WELCOME10">Shop now</a>
Avoiding nested Liquid expressions
Avoid nesting complex filter chains directly inside attributes, especially when working with query parameters like ? or &. Nested expressions with inline conditionals can cause parsing errors.
Anti-pattern (avoid):
<a href="{{ item.url | append: '?segment=' | append: user.segment | url_encode }}">View</a>
Recommended pattern:
{% assign segment_param = user.segment | url_encode %}
{% assign link_url = item.url
| append: "?segment="
| append: segment_param %}
<a href="{{ link_url }}">View</a>
<a href="https://example.com/running-shoes?segment=loyal">View</a>
Comments
0 comments