How To Set Up User-ID In GA4

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.
Click path: Admin then Data display then Reporting identityAdminData displayReporting identity
Select Blended or Observed to activate User-ID stitching.

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_id parameter 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.

  1. 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.
  2. 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.
  3. 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_id and Value to {{dlv_user_id}} (the variable you just created). Save the tag and publish the container.
Click path: Tags then Google tag then Configuration settingsTagsGoogle tagConfiguration settings
Add user_id as a configuration parameter with a Data Layer variable.

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 sendWhat Analytics seesWhy it is wrongCorrect approach
Empty string ""A logged-out user without a stable IDCan cause coding issues; not recommendedSend null instead
Blank string " "A unique user ID consisting of a spaceDoes not clear the ID; creates a fake userSend null
The string "null" or "NULL"A unique user ID with the literal value "null"Does not clear the ID; creates a fake userSend JavaScript null
Dummy or placeholder values (e.g., "12345", "test")Real user IDsSkews reports; repeated use can cause permanent data lossOnly send actual, unique IDs
Personally identifiable information (email, name)A user ID containing PIIViolates Google Analytics Terms of ServiceUse an internal identifier that reveals nothing about the person
More than 256 charactersExceeds the 256-character limitExceeds the allowed lengthUse an ID of 256 characters or less
Same ID for multiple usersMerged user profilesDistorts user counts and behavior analysisAssign a unique ID to each user
Setting user_id as a custom dimensionA high-cardinality custom dimensionCauses (other) row, consumes quota, and duplicates the built-in featureUse 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>.