This page shows how to use Liquid with event and transaction data in Blueshift. You'll find examples for event attributes, timestamps, event-based product data, and three ways to access transactions: segment-based, event-triggered, and direct transaction lookups.

All examples are verified for Blueshift's Liquid syntax and supported filters.

On this page

Access event name

Retrieve the triggering event name/type from bsft_event_context.

Liquid:

{{ bsft_event_context.event }}

Example data:

{
  "bsft_event_context": { "event": "purchase" }
}
Rendered output: purchase

Back to TOC ↑

Access event attributes

Use properties sent with the event payload.

Liquid:

Product: {{ bsft_event_context.product_name }}
Price: ${{ bsft_event_context.amount }}
Quantity: {{ bsft_event_context.quantity }}

Example data:

{
  "bsft_event_context": {
    "product_name": "Leather Wallet",
    "amount": 45,
    "quantity": 1
  }
}
Rendered output: Product: Leather Wallet
Price: $45
Quantity: 1

Back to TOC ↑

Use event timestamp

Format the timestamp associated with the event.

Liquid:

{{ bsft_event_context.timestamp | date: "%B %e, %Y" }}
{{ 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: August 20, 2025
August 20, 2025 10:30 AM

Back to TOC ↑

Event-triggered purchase details

Show purchase info in event-triggered emails.

Liquid:

Order ID: {{ bsft_event_context.order_id }}
Total: ${{ bsft_event_context.amount }}
Payment: {{ bsft_event_context.payment_method }}

Example data:

{
  "bsft_event_context": {
    "order_id": "ORD-87421",
    "amount": 129.99,
    "payment_method": "credit_card"
  }
}
Rendered output: Order ID: ORD-87421
Total: $129.99
Payment: credit_card

Back to TOC ↑

Transaction access (segment-based)

In segment-triggered campaigns, use user_transaction to access the most recent transaction that matched the segment.

Liquid:

{% if user_transaction %}
Last purchase: {{ user_transaction.order_id | default: "" }}
Brand: {{ user_transaction.hotel_brand | default: "" }}
Amount: {{ user_transaction.amount | default: "" }}
{% endif %}

Example data:

{
  "user_transaction": {
    "order_id": "ORD-87421",
    "amount": 129.99,
    "hotel_brand": "BlueStay Hotels"
  }
}
Rendered output: Last purchase: ORD-87421
Brand: BlueStay Hotels
Amount: 129.99

Back to TOC ↑

Transaction access (event-triggered)

In event-triggered campaigns, the transaction is embedded in bsft_event_context.

Liquid:

Order: {{ bsft_event_context.order_id }}
Total: {{ bsft_event_context.amount }}
First item: {{ bsft_event_context.items[0].title }}

Example data:

{
  "bsft_event_context": {
    "order_id": "ORD-87421",
    "amount": 129.99,
    "items": [
      { "title": "Running Shoes" },
      { "title": "Socks Pack" }
    ]
  }
}
Rendered output: Order: ORD-87421
Total: 129.99
First item: Running Shoes

Back to TOC ↑

Transaction lookup via mixins

Use transaction mixins like transactions.Hotel_Booking to loop through related transactions and show details.

Liquid:

{% if transactions.Hotel_Booking and transactions.Hotel_Booking.size > 0 %}
  {% for booking in transactions.Hotel_Booking %}
    Hotel: {{ booking.property }}
    Check-in: {{ booking.check_in_timestamp | date: "%b-%d-%Y" }}
  {% endfor %}
{% else %}
  No previous bookings found.
{% endif %}

Example data:

{
  "transactions": {
    "Hotel_Booking": [
      {
        "property": "BlueStay Downtown",
        "check_in_timestamp": "2025-08-20T14:30:00Z"
      }
    ]
  }
}
Rendered output: Hotel: BlueStay Downtown
Check-in: Aug-20-2025

Back to TOC ↑

Days since event

Calculate how many days have passed since this event fired.

Note: bsft_event_context is available only in event-triggered campaigns.

Liquid:

{% assign event_s = bsft_event_context.timestamp | date: "%s" %}
{% assign now_s = now | date: "%s" %}
{% assign days = now_s | minus: event_s | divided_by: 86400 %}
{{ days }} days ago

Example data:

{
  "bsft_event_context": { "timestamp": "2025-08-20T00:00:00Z" }
}
Rendered output: 2 days ago

Back to TOC ↑

Cart abandonment loop

Show items included in the cart event.

Liquid:

{% if bsft_event_context.items and bsft_event_context.items.size > 0 %}
  {% for item in bsft_event_context.items %}
    {{ item.title }} – ${{ item.price }}
  {% endfor %}
{% else %}
  Your cart is empty.
{% endif %}

Example data:

{
  "bsft_event_context": {
    "items": [
      { "title": "Running Shoes", "price": 80 },
      { "title": "Socks Pack", "price": 12 }
    ]
  }
}
Rendered output: Running Shoes – $80
Socks Pack – $12

Back to TOC ↑

Event value comparisons

Change messaging using numeric or string comparisons.

Liquid:

{% if bsft_event_context.amount >= 100 %}
  Thanks for your big purchase!
{% else %}
  Thanks for shopping with us!
{% endif %}

Example data:

{
  "bsft_event_context": { "amount": 120 }
}
Rendered output: Thanks for your big purchase!

Back to TOC ↑

Combine user + event data

Personalize event-triggered messages using user profile fields.

Liquid:

Hi {{ user.firstname }}, thanks for buying {{ bsft_event_context.product_name }}!

Example data:

{
  "user": { "firstname": "Alex" },
  "bsft_event_context": { "product_name": "Wireless Headphones" }
}
Rendered output: Hi Alex, thanks for buying Wireless Headphones!

Back to TOC ↑

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

Comments

0 comments

Please sign in to leave a comment.