Need to generate new session_id if user_id changes

Hi there. We are having the issue of more than 1 users under 1 session_id. Is there a way to generate new session_id if the user_id changes?

Thanks

Welcome to Snowplow @feihusong

You can call the following:

v3.1+:

snowplow('clearUserData', { preserveSession: false, preserveUser: true });

v2.18+:

snowplow('clearUserData', false, true);

This is only available in the latest releases of v3 and v2 of the tracker. You’ll also want to send an event straight after this as it resets the cookies and will only recreate the user_id cookie when the next event is sent.

1 Like