Time window

Learn how to use time-based filters in event expressions.

Time windows let you restrict event expressions to events that occurred within a specific time frame. They are useful for checking recent activity or events that happened during a particular period.

Syntax

The syntax for time windows is as follows:

PredicateDescription
todayMatches events that occurred today
yesterdayMatches events from yesterday
this weekMatches events in the current calendar week
this monthMatches events in the current calendar month
this yearMatches events in the current calendar year
this sessionMatches events in the current SDK session
last sessionMatches events from the last closed session
last weekMatches events in the previous calendar week
last monthMatches events in the previous calendar month
last yearMatches events in the previous calendar year
in last /*<duration>*/Matches events in a custom duration
in the last /*<duration>*/Same as above—just an alternative syntax

Examples

Check if a goal was completed today:

user has completed goal "checkout-started" today
Try in Playground

Check if a user signed up yesterday:

user has signed up yesterday
Try in Playground

Check if a product was viewed this session:

user has viewed a product this session
Try in Playground

Check if a goal was completed last session:

user has completed goal "checkout-started" last session
Try in Playground

Check if a custom event occurred last week:

user has experienced a custom event "subscription-applied" last week
Try in Playground

Check if any order was placed in the last 5 days:

user has placed an order in last 5 days
Try in Playground