Record events with a custom user ID
Set a custom user identifier to match your external data systems and track players across multiple devices.
Read time 1 minuteLast updated 19 hours ago
By default, Analytics SDK uses the UGS installation ID as the user ID for each event. This ID is different for each installation on each device, which can make it difficult to track the same user across multiple devices, or to join data between the Analytics platform and your own internal sources. To help with this situation, you can use the External User ID feature to set a specific user ID that you control.
- If you want Unity to generate user IDs for Analytics, no action is required.
- If you want to use a specific ID to match with external data (for example, other analytics sources) then you need to set an external user ID.
using Unity.Services.Core;void SetExternalUserId(){ UnityServices.ExternalUserId = "some-user-id";}
Even if you set an external user ID, the Analytics SDK still records the installation ID in the
unityInstallationIDunityPlayerIDPlayerPrefsExternalUserIdIf you are not sure what ID is current in use, you can call theusing Unity.Services.Core;void ClearExternalUserId(){ UnityServices.ExternalUserId = String.Empty;}
AnalyticsService.Instance.GetAnalyticsUserID()