How to manage IdentityMap in WebSDK tips | Community
Skip to main content
Michael_Soprano
Level 10
July 13, 2026
Question

How to manage IdentityMap in WebSDK tips

  • July 13, 2026
  • 1 reply
  • 18 views

I have got the case like this:

  1. Unrecognized User - ECID is added server side to IdentityMap 
  2. User logs in.
    a) I use email as an identity (but email has to be unique - only one in the profile - configured in Identity Service). 
    b) Data Element for that email is populated and added to the IndentityMap. I want that data element also be populated in the following events. SHould it be stored like that?
  1. Then the user logs-out 
  2. User logs in to the another account. Identity Service disjoin these profiles. I assume I need to clear IdentityMap and add new one. Any tips?

What are your tips to manage IdentityMap?

1 reply

Level 4
July 14, 2026

Hi ​@Michael_Soprano,

 

For step 2, yes, Visitor storage duration is the right choice for the email identity data element. It persists across events in the same session and survives page navigation, so subsequent events will carry the email in the identityMap without you needing to re-populate it on every event.

 

For step 4 (user logs out, different user logs in), you’re correct that you need to clear the previous identityMap. The pattern is:

 

On logout, call alloy("resetIdentities") to clear the stored identities from the SDK. Then on the new login, populate the identityMap fresh with the new user’s email. This prevents the ECID from being incorrectly linked to the new user’s profile.

 

One important caveat: resetIdentities generates a new ECID, so the pre-login anonymous session will no longer be stitched to anything. If you need to preserve the pre-login behavior for the new user, you’ll need to send their email identity immediately on login before any other events fire.