User stitching is a Premium feature that fills gaps in identity columns (most notably user_id) at the session level by analyzing the user_pseudo_id (cookie).
If a session lacks a user_id:
- Look-back: The system searches past sessions for the same
user_pseudo_id and assigns the last seen user_id to the current session. - Look-ahead: If no past ID is found, the system searches future sessions. If a login occurs later, it 'rewrites history' by assigning that future
user_id to the previous anonymous sessions.
Stitching is not limited to user_id; it can be applied to custom parameters, user properties, or URL parameters (e.g., url_params_custom.lead_id). Stitched results are stored as a struct in the stitched_ids column of the ga4_sessions table.