This guide outlines how to tag Langfuse sessions or traces for a user and site when a conversion (e.g., moving from free to paid) occurs, allowing filtering of converted vs. non-converted conversations. Since Langfuse's API doesn't natively support key-based metadata filtering (e.g., site_id
), we combine native filters with client-side processing.
- Fetch sessions for a user in a time window (e.g., last 24 hours) using
user_id
andstart_time_after
. - Fetch traces for each session using
session_id
. - Filter traces client-side by
metadata.site_id
. - Apply a score (e.g.,
24h_before_conversion=1
) to matching traces or sessions for easy filtering in Langfuse.