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

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 }
}
Rendered output: Amount: $120.00

Back to TOC ↑

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"
  }
}
Rendered output: Local time: August 20, 2025 10:30 AM

Back to TOC ↑

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" }
}
Rendered output (example): Hashed email: (MD5 hash of alex@example.com)

Back to TOC ↑

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?" }
}
Rendered output: Cleaned subject: Welcome back Ready to shop

Back to TOC ↑

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:

{}
Rendered output (example):
Search link:
https://example.com/search?q=wireless+headphones+%26+speakers

Back to TOC ↑

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>"
}
Rendered output: Plain text: Hi Alex, welcome back to our store.

Back to TOC ↑

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:

{}
Rendered output:
Rounded: 4
Ceiling: 5
Floor: 4

Back to TOC ↑

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."
    }
  }
}
Rendered output: Good news: you qualify for free shipping on your next order.

Back to TOC ↑

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"
  }
}
Rendered output (example):
<a href="https://example.com/running-shoes?code=WELCOME10">Shop now</a>

Back to TOC ↑

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>
Rendered output (example):
<a href="https://example.com/running-shoes?segment=loyal">View</a>

Back to TOC ↑

Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.