This article explains, step by step, how to use event data in your campaigns with event Jinja and aggregates. You will learn how to pull values from events (for example, the last purchase, last cart update, or last page visit) directly into your email, SMS, or other campaigns.
There are two basic approaches:
Event Jinja – works only in on‑event triggered scenarios.
Aggregates – can be used in any campaign once the value is accessible as a customer attribute.
Option 1: Use event Jinja in an on‑event triggered scenario
Read more about scenario triggers.
Use this when your campaign is triggered by the event itself (for example: send an email when a purchase event is tracked).
Step 1: Create an on‑event scenario
Go to Scenarios and create a new scenario.
Add an On event trigger.
- Select the event type you want to react to (for example, purchase).
- (Optional) Add conditions on event properties (for example, status = completed).
Step 2: Add a campaign node
After the On event node, add your preferred campaign node (Email, SMS, and more).
Open the template editor for that node.
Step 3: Insert the event Jinja into the template
Inside the template, you can access event properties via the event object:
{{ event['property_name'] }}Examples:
{{ event['purchase_id'] }}
{{ event['product_name'] }}Use this wherever you need the value, for example, in email text:
Thank you for your order {{ event['purchase_id'] }}.
We have reserved {{ event['product_name'] }} just for you.Important notes
- {{ event[...] }} works only inside campaign template nodes (email body, SMS content, and more) — not inside the On-event trigger's own filter conditions. You also can't use derived attributes such as running aggregates, event expressions, or event segmentations to define the On-event trigger itself.
Preview may not reflect the exact event data that will be used in a live execution. Always test with a real customer journey and a test profile for a fully accurate render.
Option 2: Use an aggregate to store event data on the profile and reuse it
Use this when you don't want the campaign tied to a single event trigger.
An aggregate evaluates events and calculates a result that is accessible as a customer attribute in Jinja.
Step 1: Create an aggregate for the event property
Go to Data & Assets → Data manager → Definitions -> New definition
Create a new customer aggregate.
Choose type Last (or First, depending on your use case).
-
Set:
- Event type: the event you want to read from (for example, purchase or test).
- Property: the event property you need (for example, purchase_id, product_name, status).
Time range: for example, "Last 1 day", "Last 30 days", or a custom range.
If a customer has such an event, the aggregate will calculate and make available the chosen property value as a customer attribute. If not, the aggregate value will be null (empty), and Jinja will render it as None.
Step 2: Use the aggregate in any campaign
Once the aggregate is ready, you can use it in any template (email, SMS, weblayer, and more) with Jinja:
{{ aggregates['AGGREGATE_ID'] }}Replace AGGREGATE_ID with the ID of your aggregate.
Example usage in email text:
Your last purchased product was:
{{ aggregates['69b0a2a01d0872dd283107c6'] | replace('None', 'No recent purchase') }}replace('None', 'No recent purchase') is a Jinja filter that shows the fallback when the value is missing or empty.
Important notes
When a new event is tracked or imported, the aggregate needs some time to recalculate. On larger projects, this isn't instantaneous, so if you reference the aggregate within milliseconds or a few seconds after the event is created, you may still see the previous value. To avoid this, consider adding a short wait (for example, 1 minute) before using the aggregate in your scenario.
Summary: When to use which approach?
- Use event Jinja ({{ event[...] }}) when:
An event immediately triggers the campaign.
You need data from that specific event instance.
- Use aggregates ({{ aggregates['...'] }}) when:
You want to reuse the value from the most recent (or first) event across multiple campaigns.
The campaign isn't necessarily triggered by that event (for example, a scheduled newsletter).