Overview
If a player reinstalls your game or clears their PlayerPrefs and is using Anonymous Sign-In, they will receive a brand-new `player_id` and `user_id`. This means they lose access to all data (Cloud Save, Leaderboards, etc.) stored against their previous `player_id`. This article explains why this happens and how to prevent it.
Symptoms
You or your players may observe one or more of the following:
- A returning player can no longer access their saved game data after reinstalling the app
- A player appears in Analytics under a new `user_id` with a new `player_id`
- Your backend records show two distinct user identities for the same physical device
Cause
Unity's Anonymous Sign-In generates a `player_id` and Analytics generates a `user_id` that are tied to the local device storage (PlayerPrefs). When the app is reinstalled or PlayerPrefs are cleared, that local token is gone, and Unity Authentication creates a new anonymous identity for the player on their next sign-in.
This affects two separate identifiers:
| Identifier | Used by | Resets on reinstall? |
|---|---|---|
| `player_id` | Authentication, Cloud Save, all UGS backend services | ✅ Yes |
| `user_id | Unity Analytics | ✅ Yes |
Important: It is the reset of the `player_id` that causes loss of game data access. The `user_id` reset is a secondary effect; it causes a gap in Analytics data, but is not itself the reason the player cannot reach their saved data.
Solution
Option 1: Use an Identity Provider (Recommended)
Switch from Anonymous Sign-In to a persistent Identity Provider such as:
- Unity Player Accounts
- Apple, Google Play, Steam, or any other supported provider
- Oculus / Meta Platform (recommended for Meta Quest apps)
When a player signs in through an Identity Provider, their `player_id` is linked to their account, not to local device storage. Reinstalling the app or playing on a second device will not change their `player_id`, and they will retain access to all their backend data.
Unity Authentication documentation:
Option 2: Persist the Analytics user_id across reinstalls
If you need Analytics continuity independent of authentication, you can instruct Unity Analytics to use the device's IDFV (Identifier for Vendor) as the `user_id`. This value persists across reinstalls on the same device.
// Use IDFV as the Analytics user_id for continuity across reinstalls
if (SystemInfo.deviceUniqueIdentifier != null && SystemInfo.deviceUniqueIdentifier != "n/a")
{
Debug.Log("Using device identifier as Analytics user_id");
UnityServices.ExternalUserId = SystemInfo.deviceUniqueIdentifier;
}
Tip: For even stronger continuity, set `UnityServices.ExternalUserId` to the player's `player_id` after a successful Identity Provider sign-in. This ties Analytics to the authenticated player identity, ensuring Analytics data consistency across devices.
Prevention
To avoid this issue in new projects:
- Avoid relying on Anonymous Sign-In as a long-term identity: it is suitable only for guest access, not for players who should retain persistent data.
- Implement an Identity Provider early: retrofitting authentication after launch is significantly more complex.
- Test your uninstall/reinstall workflow before shipping — sign in, save data, reinstall, sign in again, and verify the player can access their previous data.
- Provide a sign-in prompt that guides players to link their account to an Identity Provider, so their progress is protected.
Identifying affected players
If you need to link a player's old and new identities for investigation purposes, Unity Analytics device data may help. Players on the same physical device share an IDFV value, which is available in Analytics event data. This allows you to correlate a previous `user_id` with a new one on the same device, even after a reinstall.