User-ID in GA4 connects logged-in user behavior across devices and sessions. You send a unique identifier from your own system, and Analytics uses it to de-duplicate users and build cross-device journeys.
This guide covers the exact implementation steps for gtag.js and Google Tag Manager, explains how User-ID differs from device ID, and lists the values you must never send. Follow along with your GA4 property open.
What User-ID Does
User-ID is a feature that lets you associate your own persistent identifiers with individual users. When you send a unique ID for each signed-in user, Google Analytics can connect their behavior across different sessions, devices, and platforms. Analytics treats each user ID as a separate user, which gives you more accurate user counts and a fuller picture of the customer journey.
To use User-ID, you must create a unique ID for each user on your own system and assign it consistently, typically at login. Each ID must be 256 characters or less. Do not reuse IDs across users; assigning the same ID to multiple people will merge their activity and distort your reports. For example, if John and Mary accidentally share the same ID, their combined browsing and purchase history will appear as one user.
Once you send user IDs, you can compare signed-in and signed-out behavior using the Signed in with user ID dimension. You can also drill into individual user timelines with the User Explorer exploration. If you link Analytics to BigQuery, user IDs are exported regardless of consent status. Note that data collected before you implement User-ID is not reprocessed, and user IDs from one property cannot be mixed with another.
For the feature to work, your property's reporting identity must be set to Blended or Observed. You change this in Admin > Data display > Reporting identity. The Device based option ignores user IDs entirely.
Improper implementation can hit per-user-per-day event limits. Always send a real, unique ID. Repeatedly setting a blank or dummy value can cause permanent data loss. For more on the reporting identity options, see Google Analytics Admin: Every Setting And Where To Find It.
User-ID Vs Device ID Vs Google Signals
GA4 uses three identity spaces to stitch user journeys: User-ID, Device ID, and Modeling. Which ones are active depends on your reporting identity setting.
User-ID is the most accurate space because it relies on your own login-based identifiers. Device ID is the default for anonymous users: on websites it is the client ID, on apps the app-instance ID. Modeling fills in gaps when users decline analytics identifiers; it uses data from similar users who have accepted cookies.
For a deeper look, read What Is Cross-Network In Google Analytics 4?.
Your property's reporting identity is set in Admin > Data display > Reporting identity. You have three options:
- Blended: evaluates User-ID first, then Device ID, then Modeling.
- Observed: evaluates User-ID then Device ID. No modeling is applied.
- Device based: uses only Device ID. User-ID data is ignored even if you send it.
To get the full benefit of Blended or Observed, you need to collect user IDs and have enough signed-in traffic to obfuscate individual identities. Reports may be subject to data thresholds as a result. You can switch between options at any time; the change does not affect data collection or processing and has no permanent impact on historical data.
Short on time? Analytics Art can check this in your property for you.
Sending User-ID With The Google Tag
You send the user ID as a configuration parameter, not as an event parameter or a custom user property. The user_id field is a reserved system parameter. Do not register it as a custom dimension in the GA4 interface, and do not pass it inside the user_properties object.
Before you begin, make sure you have a GA4 property with a web data stream, the Google tag installed on your site, and the Editor role or above.
The value you send depends on the user's sign-in state:
- Never signed in: do not send the
user_idparameter at all. - Signed in: send their unique identifier.
- Was signed in, then signed out: send
null(JavaScript null, not the string "null").
With gtag.js, you add the user_id to the config command on every page. A minimal example:
// Determine sign-in state with your own logic
if (userIsSignedIn) {
gtag('config', 'G-XXXXXXXX', { 'user_id': 'abc123' });
} else if (userWasSignedIn) {
gtag('config', 'G-XXXXXXXX', { 'user_id': null });
} else {
gtag('config', 'G-XXXXXXXX'); // no user_id sent
}Replace 'G-XXXXXXXX' with your measurement ID. The ID you send must be 256 characters or less. When a user signs out, setting user_id to null clears the association; subsequent events are not tied to that user. Do not send an empty string (""), a blank string, or the quoted word "null".
You can also use the gtag('set', { user_id: '...' }) command to set the ID for all subsequent events on the page. The key point is that user_id must be a configuration-level setting, never attached to individual event hits.
Sending User-ID With Tag Manager
Tag Manager sends the user ID through a Data Layer variable that you attach to your Google tag's configuration settings. The setup has three steps.
- Push the user ID to the Data Layer. Place this code above the Tag Manager container snippet on every page. It must run before the container loads so the value is available for the initial page view.
if (/* user is signed in */) { dataLayer.push({ 'user_id': 'USER_ID' }); } else if (/* user signed out */) { dataLayer.push({ 'user_id': null }); } // If never signed in, do nothing. - Create a Data Layer variable. In Tag Manager, go to Variables > User-Defined Variables > New. Choose Data Layer Variable, name it (for example, "dlv_user_id"), and set the Data Layer Variable Name field to
user_id. Save the variable. - Add the variable to your Google tag. Open your Google tag (the one that fires on all pages). Under Configuration settings, add a new row: set Parameter to
user_idand Value to {{dlv_user_id}} (the variable you just created). Save the tag and publish the container.
If a user signs in or out after the page loads, push the updated value to the Data Layer again. Tag Manager will pass it to the Google tag on the next event. Just as with gtag.js, never send an empty string or the string "null". After logout, the only acceptable value is JavaScript null.
For a deeper explanation of the Data Layer, see The Google Tag Manager Data Layer Explained.
What You Must Never Send As A User-ID
Certain values cause data problems, violate policy, or break the User-ID feature. The table below lists what you must avoid.
| Value you send | What Analytics sees | Why it is wrong | Correct approach |
|---|---|---|---|
Empty string "" | A logged-out user without a stable ID | Can cause coding issues; not recommended | Send null instead |
Blank string " " | A unique user ID consisting of a space | Does not clear the ID; creates a fake user | Send null |
The string "null" or "NULL" | A unique user ID with the literal value "null" | Does not clear the ID; creates a fake user | Send JavaScript null |
| Dummy or placeholder values (e.g., "12345", "test") | Real user IDs | Skews reports; repeated use can cause permanent data loss | Only send actual, unique IDs |
| Personally identifiable information (email, name) | A user ID containing PII | Violates Google Analytics Terms of Service | Use an internal identifier that reveals nothing about the person |
| More than 256 characters | Exceeds the 256-character limit | Exceeds the allowed length | Use an ID of 256 characters or less |
| Same ID for multiple users | Merged user profiles | Distorts user counts and behavior analysis | Assign a unique ID to each user |
Setting user_id as a custom dimension | A high-cardinality custom dimension | Causes (other) row, consumes quota, and duplicates the built-in feature | Use the reserved user_id parameter only |
After a user logs out, you must send null to clear the previous ID. Do not send undefined (which omits the parameter entirely) if you need to disassociate the user; null is the explicit signal. For more on custom dimensions and cardinality, see Custom Dimensions In GA4.
Also remember that the User-ID feature is subject to the Analytics SDK / User-ID Feature Policy. Any data collected before you implement User-ID is not reprocessed.
Frequently Asked Questions
How Do I View User-ID Data In GA4 Reports?
You can use the 'Signed in with user ID' dimension to create comparisons in standard reports or segments in Explorations. Raw user_id values are not available in standard reports, but you can see them in the User Explorer exploration under 'Effective user ID'. For raw access, export data to BigQuery.
What Is The 'Signed In With User ID' Dimension?
It is a built-in dimension that shows whether a user has a user ID associated with their activity. You can use match types like 'exactly matches' or 'does not exactly match' to compare authenticated and anonymous user behavior in your reports.
Can I Set User-ID As A Custom Dimension?
No. The user_id is a reserved system parameter. Registering it as a user-scoped custom dimension creates a high-cardinality dimension that can push data into the (other) row and consume your custom dimension quota. Always set it as a configuration parameter.
How Do I Find My GA4 Property ID?
In Admin, under Property settings, click Property details to see the numeric property ID. You can also find it in the property selector. For detailed steps, see our guide on <a href='/ga4-property-id/'>How To Find Your GA4 Property ID</a>.
What Happens If I Send An Empty User-ID?
An empty user ID value is sent, and the user is treated as logged out without a stable ID. Google recommends null instead, because an empty string can cause coding issues, and after logout null is the only acceptable value.
How Do I Create A Google Analytics Account?
Go to analytics.google.com, click Start measuring, and follow the steps to create an account, property, and data stream. You will need a Google account. For a full walkthrough, see <a href='/add-google-analytics-to-website/'>How To Add Google Analytics To Your Website</a>.
Related GA4 Guides
- Where To Find Your GA4 Measurement ID (G-XXXXXXX)Learn where to find your GA4 measurement ID in the Admin panel, how it differs from property and UA IDs, and where to paste it for GTM, WordPress, Shopify, and gtag.js.
- How To Use Google Tag Assistant To Test GA4 TagsLearn how to use Google Tag Assistant to debug your GA4 tags, check events, and fix connection issues. Step-by-step guide with screenshots.
- How To Add Google Analytics To Your WebsiteAdd Google Analytics 4 to your website: create a property, copy a measurement ID, and install the Google tag. Step-by-step guide for direct, GTM, or CMS installation.
- Google Analytics Admin: Every Setting And Where To Find ItFind every GA4 Admin setting with exact click paths. Learn where to manage accounts, properties, data streams, product links, and user access in Google Analytics.
- How To Add Users To Google Analytics 4Learn how to add users to Google Analytics 4 step by step. Understand roles, data restrictions, and account vs property access. Manage your GA4 users securely.
More in Setup & Tags or browse all GA4 guides.