Now sending an actually unique parameter so matching in the future is simpler
This commit is contained in:
@@ -733,14 +733,15 @@ def _process_single_reservation(
|
|||||||
room_stay=[room_stay],
|
room_stay=[room_stay],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Always send md5_unique_id as the primary tracking ID
|
||||||
|
# This is guaranteed to fit in 64 chars and has low collision risk
|
||||||
|
res_id_value = reservation.md5_unique_id
|
||||||
res_id_source = "website"
|
res_id_source = "website"
|
||||||
klick_id = None
|
|
||||||
|
|
||||||
|
# Determine the source based on available click tracking data (for informational purposes)
|
||||||
if reservation.fbclid != "":
|
if reservation.fbclid != "":
|
||||||
klick_id = str(reservation.fbclid)
|
|
||||||
res_id_source = "meta"
|
res_id_source = "meta"
|
||||||
elif reservation.gclid != "":
|
elif reservation.gclid != "":
|
||||||
klick_id = str(reservation.gclid)
|
|
||||||
res_id_source = "google"
|
res_id_source = "google"
|
||||||
|
|
||||||
# Get utm_medium if available, otherwise use source
|
# Get utm_medium if available, otherwise use source
|
||||||
@@ -757,7 +758,7 @@ def _process_single_reservation(
|
|||||||
|
|
||||||
hotel_res_id_data = HotelReservationIdData(
|
hotel_res_id_data = HotelReservationIdData(
|
||||||
res_id_type=RESERVATION_ID_TYPE,
|
res_id_type=RESERVATION_ID_TYPE,
|
||||||
res_id_value=klick_id,
|
res_id_value=res_id_value,
|
||||||
res_id_source=res_id_source,
|
res_id_source=res_id_source,
|
||||||
res_id_source_context=res_id_source_context,
|
res_id_source_context=res_id_source_context,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -814,10 +814,10 @@ class ConversionService:
|
|||||||
advertising_partner: str | None,
|
advertising_partner: str | None,
|
||||||
session: AsyncSession | None = None,
|
session: AsyncSession | None = None,
|
||||||
) -> Reservation | None:
|
) -> Reservation | None:
|
||||||
"""Match reservation by advertising tracking data (fbclid/gclid/utm_campaign).
|
"""Match reservation by advertising tracking data (fbclid/gclid/md5_unique_id).
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
advertising_campagne: Truncated tracking ID
|
advertising_campagne: Tracking ID from PMS (could be truncated click_id or md5_unique_id)
|
||||||
hotel_id: Hotel ID for filtering
|
hotel_id: Hotel ID for filtering
|
||||||
guest_first_name: Guest first name for disambiguation
|
guest_first_name: Guest first name for disambiguation
|
||||||
guest_last_name: Guest last name for disambiguation
|
guest_last_name: Guest last name for disambiguation
|
||||||
@@ -831,12 +831,14 @@ class ConversionService:
|
|||||||
"""
|
"""
|
||||||
if session is None:
|
if session is None:
|
||||||
session = self.session
|
session = self.session
|
||||||
# Find reservations where fbclid or gclid starts with the truncated value
|
# Find reservations where:
|
||||||
|
# - fbclid/gclid starts with the advertising_campagne value, OR
|
||||||
|
# - md5_unique_id matches exactly (for direct ID matching)
|
||||||
query = select(Reservation).where(
|
query = select(Reservation).where(
|
||||||
or_(
|
or_(
|
||||||
Reservation.fbclid.like(f"{advertising_campagne}%"),
|
Reservation.fbclid.like(f"{advertising_campagne}%"),
|
||||||
Reservation.gclid.like(f"{advertising_campagne}%"),
|
Reservation.gclid.like(f"{advertising_campagne}%"),
|
||||||
Reservation.utm_campaign.like(f"{advertising_campagne}%"),
|
Reservation.md5_unique_id == advertising_campagne,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user