Skip to main content

Identity Stitching

tip

On this page, <package> can be one of: web, mobile, unified

Identity stitching is the process of taking various user identifiers and combining them into a single user identifier, to better identify and track users throughout their journey on your site/app.

Stitching users together is not an easy task: depending on the typical user journey the complexity can range from having individually identified (logged in) users, thus not having to do any extra modelling to never identified users mainly using the same common public device (e.g. school or library) where it is technically impossible to do any user stitching. As stitching is a reiterative process as it constantly needs to be updated after each incremental run for a desirably large range of data, compute power and extra expenses as well as time constraints may limit and dictate the best course of action.

Session stitchingโ€‹

For the out-of-the-box user stitching we opted for the sweet spot method: applying a logic that the majority of our users will benefit from while keeping in mind not to introduce compute-heavy calculations still reaping ideal benefits.

How this works is that the unified, web, and mobile packages contain a User Mapping module that aims to lin non-permanent user identifiers, which is typically the domain_userid/device_user_id (but it can be altered to be any custom user identifier) to the "official" identifier stored within the user_id field. The logic is to take the latest user_id per domain_userid/device_user_id.

The domain_userid/device_user_id is cookie/device based and therefore expires/changes over time, where as user_id is typically populated when a user logs in with your own internal identifier (dependent on your tracking implementation). If you do not currently set a user_id as part of your tracking for logged-in users, we recommend that you begin doing this as without some assigned ID it is not possible to stitch domain_userid together.

This mapping is applied to the sessions table by a post-hook which updates the stitched_user_id column with the latest mapping. If no mapping is present, the default value for stitched_user_id is the domain_userid/device_user_id. This process is known as session stitching, and effectively allows you to attribute logged-in and non-logged-in sessions back to a single user.

Session stitching in the Unified Digital ModelSession stitching in the Unified Digital Model

If required, this update operation can be disabled by setting in your dbt_project.yml file (selecting one of web/mobile, or both, as appropriate):

dbt_project.yml
vars:
snowplow_<package>:
snowplow__session_stitching: false

In the unified package and also in the web package, since version 0.16.0, it is also possible to stitch onto the page views table by setting the value of snowplow__page_view_stitching to true. It may be enough to apply this with less frequency than on sessions to keep costs down, by only enabling this at runtime (on the command line) on only some of the runs.

Cross platform stitchingโ€‹

Since the arrival of the snowplow_unified package all the user data is modelled in one place. This makes it easy to effectively perform cross-platform stitching, which means that as soon as a user identifies themselves by logging in as the same user on separate platforms, all the user data will be found within one package making it really convenient for perform further analysis.

Custom solutionsโ€‹

User mapping is typically not a 'one size fits all' exercise. Depending on your tracking implementation, business needs and desired level of sophistication you may want to write bespoke logic. Please refer to this blog post for ideas. In addition, the web and unified packages offer the possibility to change what field is used as your stitched user id, so instead of user_id you can use any field you wish (note that it will still be called user_id in your mapping table), and by taking advantage of the custom sessionization and users you can also change the field used as the domain_user_id (for the web model) or user_identifier (unified model). We plan to add support for these features to the mobile package in the future.

Overviewโ€‹

Overview of stitching scenariosOverview of stitching scenarios

(1) it is most convenient to use the Unified Digital Model so that all of these events will be modelled into the same derived tables regardless of platform

(2) if it is the same mobile/web device and the user identifies by logging in at a later stage while still retaining the same domain_userid/device_user_id, the model will update the stitched_user_id during session_stitching

(3) if it is the same mobile/web device and the user identifies by logging in while still retaining the same domain_userid/device_user_id, the model will update the stitched_user_id during session_stitching

(4) if it is the same mobile device cross-navigation tracking and stitching can be applied (coming soon!)

Was this page helpful?