Sub topic 6
How GA4 Recognizes a User: Client ID and User-ID
Prerequisites
You should understand that GA4 records interactions as events. You should also know basic JavaScript and understand that a website can have both anonymous visitors and signed-in users.
GA4 does not identify a person from a single event alone. It uses identifiers attached to events, then uses those identifiers to group events into user activity.
Client ID: the browser-level identifier
A client ID is an identifier that GA4 assigns to a web browser and device combination. For example, a visitor using Chrome on a laptop might receive one client ID. The same person using Safari on a phone receives a different identifier.
GA4 usually stores the web client ID in the Google Analytics cookie. The identifier is pseudonymous, which means it does not directly contain the person's name or email address.
The client ID helps GA4 answer questions such as:
- How many distinct browser-based users visited?
- Which events came from the same browser?
- How many sessions did that browser start?
A client ID can change when a visitor clears cookies, uses private browsing, changes browsers, or uses another device. Therefore, client ID-based users are not necessarily unique people.
User-ID: an application-level identifier
A User-ID is an identifier that your website or app sends after a person signs in. Your system creates the value, such as u_12345, and sends it consistently for that account.
A User-ID should be:
- Stable for the same account.
- The same across the person's authorized devices.
- Free of personally identifying information, such as an email address or full name.
- Sent only when your privacy policy and consent requirements allow it.
The User-ID lets GA4 connect activity from a signed-in user on multiple browsers or devices. It does not replace the client ID. GA4 can use the client ID to recognize the browser and the User-ID to connect signed-in activity to an account.
// Set a user property and a User-ID for signed-in visitors
gtag('set', 'user_properties', {
plan_type: 'premium'
});
gtag('config', 'G-XXXXXXXXXX', {
user_id: 'u_12345'
});Send the User-ID after login and continue sending it while the user is signed in. Clear or stop sending it when the user signs out. Never send a value that directly identifies a person.
How the identifiers fit together
The client ID is useful for anonymous behavior on one browser. The User-ID is useful for authenticated behavior across devices. A report that uses users may therefore change depending on the selected reporting identity and whether User-ID data is present.
| Identifier | Usually created by | Main scope | Common limitation |
|---|---|---|---|
| Client ID | GA4 on the web | Browser and device | Changes when cookies or devices change |
| User-ID | Your application | Signed-in account | Exists only when your app sends it correctly |
Common errors
Do not use an email address as the User-ID. Hashing an email does not automatically make it suitable if your implementation or policy prohibits sending derived personal data.
Do not create a new User-ID on every page view. That prevents GA4 from recognizing the same account consistently.
Do not assume client IDs equal people. One person may have several client IDs, and several people may use one shared browser.
If you need account-level analysis, verify that the User-ID is present on the relevant events. Events sent before sign-in may remain associated only with the anonymous device context rather than automatically becoming account history.
Exercise
A customer visits on a laptop, signs in with User-ID u_42, then purchases on a phone while signed in. Which identifier helps GA4 connect the purchase to the laptop account activity?
Show answer
The User-ID u_42 connects the signed-in activity across the laptop and phone. Each device still has its own client ID.