---
title: "Set User ID"
slug: "set-user-id"
updated: 2026-05-29T13:30:44Z
published: 2026-06-05T12:54:43Z
canonical: "docs.xtremepush.com/set-user-id"
stale: true
---

> ## Documentation Index
> Fetch the complete documentation index at: https://docs.xtremepush.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Set User ID

Link a device profile to an identified user profile

A [device profile](/documentation/docs/users#device-profile) can be linked to an identified [user profile](/documentation/docs/users#user-profile) if your SDK integration provides a unique identifier known as the *User ID*. This can be useful to allow integration with your own CRM backend. At the point where the customer is identifiable and their customer ID is available the ID can be set. This is often at sign-in in the mobile app or on the website. The SDK methods are shown below:

**Swift**

```swift
XPush.setUser("CUSTOMER_ID")
```

**Objective-C**

```objectivec
[XPush setUser:@"CUSTOMER_ID"];
```

**Java**

```java
mPushConnector.setUser("CUSTOMER_ID");
```

**Web**

```Web
xtremepush('set', 'user_id', 'CUSTOMER_ID');
```

**Xamarin**

```Xamarin
DependencyService.Get<IXPushDelegate>().SetUser("CUSTOMER_ID");
```

**Titanium**

```Titanium
Alloy.Globals.xtremepush.setUser("CUSTOMER_ID");
```

**PhoneGap**

```PhoneGap
XtremePush.setUser('CUSTOMER_ID')
```

## Association behaviour

Every device profile is connected to an *anonymous* user profile by default.

When setting the User ID:

- If the User ID does not already exist in the Xtremepush project, the current *anonymous* user profile will become *identified* by the User ID, maintaining any existing attributes and message/event history.
- If the User ID already exists on another user profile, the device profile will be re-associated to the *identified* user profile with the matching User ID. Any attributes or message/event history on the *anonymous* profile will be lost.
- If setting the User ID to an empty value, the device profile will be re-associated to a new *anonymous* profile, leaving the previous *identified* profile intact.

> [!TIP]
> Set User ID first
> 
> Because the device may be re-associated to a different user profile, it is usually recommended to set the User ID before setting attributes or firing events to trigger campaigns, so the *identified* user profile is used.
