Changing `userID` after launch

We’ve been using Intercom in our app for years, but now we’d like to make a change to the identifying value that it passes to Intercom.registerUser(withUserID: userID). We’re planning to attach the old identifying value as a new property - say customID - via Intercom.updateUser().

If we move forward, what would happen to our user data if we made the change to registerUser? Our guess is that Intercom would create a new user (since userID is different).

Alternatively, is it possible to alter the userID for active users with an approach like this?

  1. Pass the old/current value - say “oldID” - to registerUser
  2. Use updateUser to change that value:

    let userAttributes = ICMUserAttributes()
    userAttributes.userId = newID
    userAttributes.customID = oldID
    Intercom.updateUser(userAttributes)

Please let us know what effects these changes could have on our data. I’m happy to provide more details if that helps. Thanks!

Hey @Ogel :wave:

Yep that’s correct, Intercom will create a new user if you pass in a different user_id to the registerUser method. It’s not possible to change user_ids through the mobile SDKs as you’ve described unfortunately.

You could do it via our REST API though. You’ll need to issue an update user request using the internal Intercom id to identify the user and with the new user_id supplied as a parameter.

Would this be an option?

Something to be aware of if you go down this route is that the SDKs have a user store which caches user identities and will persist across upgrades of your mobile app. Only calling the logout method or deleting the app will clear the store.

So if you want to change your user_id scheme, you’ll need to write some migration logic to clear the old user identities. Something like this for example:

onLaunch() {
  firstLaunchNewVersion?() {
    Intercom.logout();
    Intercom.registerUser(withUserID: newID);
  }
}

Hope this helps! Let me know if you’ve any further questions.

Cheers,
Matthew

Hi Matthew,

I am using this code in ios (Swift) and this is not logging the user out and back in with a new ID:

Intercom.logout()
Intercom.registerUser(withEmail: email)

The user still shows using the old ID and never appears as a new user with new ID. Is this still supported? I just want to be able to track user events before they log in, then update their profile. I realize I end up with two users but I can cross reference them at least.

Hey @David_Frey!

According to our developer docs:
You should only unregister an identified user. Unregistering an unidentified user will result in orphan records that cannot be merged in future.

If you want to track user events before they log in then that should be fine. Instead of calling logout() you should just need to call the registerUser(withEmail: email) method when they log in :+1:

Thanks Adam. That’s exactly what I did and it works perfectly.

1 Like