Skip to Content
ProcessesTasksProcessingGuestLoyaltyTask

GuestLoyaltyTask

The GuestLoyaltyTask computes comprehensive guest loyalty metrics based on booking and stay history. It calculates key performance indicators like lifetime value, stay counts, and booking patterns.

Overview

This task analyzes guest behavior across all their reservations to:

  • Calculate total stays and lifetime values
  • Identify returning guests and loyalty categories
  • Track booking patterns and preferences
  • Compute time between bookings
  • Assign loyalty segments

Flow Diagram

Data Transformations

Calculated Metrics

Guest-Level Metrics

MetricDescriptionType
staysTotal number of completed staysInteger
total_stay_nightsTotal nights across all staysInteger
avg_stay_nightsAverage nights per stayFloat
max_booking_windowLongest lead time in daysInteger
avg_booking_windowAverage booking lead timeFloat
nunique_properties_visitedNumber of different properties stayed atInteger
first_booking_dateDate of first bookingDate
last_booking_dateDate of most recent bookingDate
first_check_in_dateDate of first check-inDate
last_check_in_dateDate of last check-inDate
last_check_out_dateDate of last check-out (past only)Date
next_check_out_dateDate of next check-out (future)Date
future_checkinsNumber of future check-insInteger
next_check_in_dateDate of next check-inDate
lifetime_total_valueSum of all revenue (room + F&B + other)Decimal
avg_total_net_revenue_per_stayAverage total revenue per stayDecimal
lifetime_room_valueSum of room revenue onlyDecimal
avg_room_net_revenue_per_stayAverage room revenue per stayDecimal
last_stayed_property_idProperty ID of last stayString
last_booked_property_idProperty ID of last bookingString
last_booked_channelChannel of last bookingString
last_booked_sourceSource of last bookingString
last_booked_travel_agentTravel agent of last bookingString
last_booked_market_segmentMarket segment of last bookingString
last_booked_rate_codeRate code of last bookingString
properties_visitedComma-separated list of property IDsString
returning_guestTrue if stays > 1Boolean
stays_categoryLoyalty category based on stay countString

Reservation-Level Metrics

MetricDescriptionType
nth_bookingSequential booking number for this guest clusterInteger
time_between_bookingsDays since previous bookingInteger

Loyalty Categories

Guests are assigned to categories based on their stay count:

Models

Requires

  • ProcessedGuestModel - Guest data from previous processing steps
  • ProcessedReservationModel - Reservation data with metrics

Provides

  • ProcessedGuestModel - Guest data enriched with loyalty metrics
  • ProcessedReservationModel - Reservations enriched with nth_booking

Incremental Behavior

  • When running in incremental mode the task calculates loyalty metrics based on the full dataset, and then extracts only newly added guest_id/res_id records. These are written to ProcessedAddedGuestModel and ProcessedAddedReservationModel respectively.
  • During merge the added models are unioned into the existing Processed* models and deduplicated by guest_id and res_id.

Dependencies

This task must run after:

  • GuestMatchingTask (or GuestMatchingCheckTask) - Requires guest_cluster_id
  • ReservationMetricsTask - Requires stay_nights and booking_window

Best Practices

  1. Always run after guest matching to ensure accurate guest_cluster_id values
  2. Monitor memory usage when processing large guest databases
  3. Use checkpointing to prevent stack overflow with complex lineage
  4. Validate stay counts match business expectations
  5. Consider revenue columns may be optional depending on data source
Last updated on