Rank flexible fares first when the dates keep moving
A traveler has searched Chicago to Lisbon four times in ten minutes, moving the departure date each time. Your pricing engine prices each search as it arrives, and the three dates before it reach the ranker after the new list is on the screen. Someone who moves the date three times is telling the search they are flexible on it. The next results should lead with the flexible fare and the cheapest-date view, while the traveler is still at the search form.
searches_session- Flight searches run this visit
dates_tried_session- Separate departure dates searched this visit
depart_dates_session- The departure dates searched this visit
Puts the flexible fare and the cheapest-date view at the top once a visit reaches three departure dates for one route, and passes the dates tried in so the calendar opens on the span the traveler has been covering.
from snowplow_signals import (
Attribute, Event, EventProperty, StreamAttributeGroup, domain_sessionid,
)
flight_search = Event(name="flight_search", vendor="com.example", version="1-0-0")
depart_date = EventProperty(vendor="com.example", name="flight_search", major_version=1, path="depart_date")
searches_session = Attribute(
name="searches_session",
type="int32",
events=[flight_search],
aggregation="counter",
default_value=0,
)
dates_tried_session = Attribute(
name="dates_tried_session",
type="int32",
events=[flight_search],
aggregation="approx_count_distinct",
property=depart_date,
)
depart_dates_session = Attribute(
name="depart_dates_session",
type="string_list",
events=[flight_search],
aggregation="unique_list",
property=depart_date,
)
# Keyed on the visit, so the dates tried belong to this comparison and not to last month's trip.
trip_search_dates = StreamAttributeGroup(
name="trip_search_dates",
version=1,
attribute_key=domain_sessionid,
owner="you@example.com",
attributes=[searches_session, dates_tried_session, depart_dates_session],
)// In the code that sends a search request to your search and pricing engine
const traveler = await signals.getServiceAttributes({
name: "trip_search_dates",
attribute_key: "domain_sessionid",
identifier: sessionId,
});
// { searches_session: 4, dates_tried_session: 3, depart_dates_session: ["2026-11-06", "2026-11-07", "2026-11-13"] }
if (traveler.dates_tried_session >= 3) {
search.query({
...request,
rankFirst: ["flexible_fare", "cheapest_date_view"],
calendarSpan: traveler.depart_dates_session,
});
}