How to Set Up User ID in Google Analytics

Cody Schneider9 min read

Tired of seeing thousands of anonymous "users" in your reports? Google Analytics 4 can tell you how many people visited your site, but connecting the dots of a single user's journey - from their phone in the morning to their laptop at night - is nearly impossible out of the box. This is where the User-ID feature completely changes the game. This article will walk you through exactly how to set up and verify a User-ID in GA4, giving you a crystal-clear view of how real people interact with your business.

GraphedGraphed

Still Building Reports Manually?

Watch how growth teams are getting answers in seconds — not days.

Watch Graphed demo video

What Exactly is a User-ID in GA4?

In standard Google Analytics, each device is treated as a separate user. If someone visits your site on their iPhone and then again on their work computer, GA4 counts them as two different users. This inflates your user counts and makes it impossible to understand the full customer journey.

The User-ID is a unique, anonymous identifier that you assign to your users once they log into your website or app. By sending this ID along with their activity data to Google Analytics, you are telling GA: "Hey, all of these sessions, from this phone, that tablet, and that laptop? They all belong to a single, known individual."

This allows GA4 to stitch together all of that user's activity into one unified profile, giving you a true cross-device, cross-platform view of their behavior.

How is User-ID Different from Client ID and Google Signals?

GA4 uses a hierarchy of methods to try and identify users. Understanding the difference is key:

  • Client ID: This is the default. It's an anonymous string stored in a user's browser cookie. It works well for tracking anonymous sessions on a single device, but if a user clears their cookies or switches devices, a new Client ID is generated.
  • Google Signals: This relies on data from users who are signed into their Google accounts and have "Ads Personalization" turned on. It helps bridge the device gap but is based on Google's data (not yours) and only works for a subset of your users. The data is also aggregated and modeled, not a one-to-one mapping.
  • User-ID: This is the most accurate and powerful method. It uses the first-party data you generate when a user logs in. You are in complete control of the ID and it permanently links a user's activity as long as they are signed in.

When you set up User-ID, GA4 will prioritize it over the other two methods whenever a user is logged in, giving you the most reliable data possible.

GraphedGraphed

Still Building Reports Manually?

Watch how growth teams are getting answers in seconds — not days.

Watch Graphed demo video

Why is User-ID Tracking So Important?

Moving from anonymous hit-counting to person-centric tracking unlocks profound insights that can directly impact your strategy and revenue.

Get an Accurate User Count

The most immediate benefit is data accuracy. Instead of reporting an inflated number of users based on device count, you'll finally know the true size of your logged-in user base. Understanding how many actual people power your business is a foundational metric that informs everything from server costs to customer acquisition strategy.

Understand the Full Customer Journey

Imagine this common scenario without User-ID:

  1. A person clicks a Facebook ad on their phone during their morning commute (Session 1).
  2. Later, at work, they Google your brand and browse your product pages on their desktop (Session 2).
  3. That evening, they pull up your site on their tablet and finally make a purchase (Session 3).

Standard GA sees this as three disconnected, low-value visits from three "users." It fails to attribute the purchase to the initial Facebook ad, making your campaigns seem less effective. With User-ID, GA ties these sessions together, revealing the complete conversion path and giving you the evidence needed to invest in channels that are actually working.

Enable Powerful User-Level Analysis

Once you track individual users, you can move beyond aggregated metrics and get personal with your analysis. You can create segments based on real behavior:

  • Power Users: Identify users who log in daily and use key features, then look at how they were acquired.
  • High-Value Customers: Analyze the common behaviors and acquisition paths of users with a high lifetime value.
  • Churn Risk: Segment users who haven't logged in for 30 days to understand their previous behavior and inform re-engagement campaigns.

Build a Foundation for Smarter Marketing

The clean, accurate data you get from User-ID feeds directly back into your marketing efforts. You can build more precise audiences for remarketing based on specific actions (e.g., users who viewed a product but didn't buy, regardless of device). Clearer attribution helps you allocate your budget more effectively, shifting spend to the channels that introduce users who eventually convert.

GraphedGraphed

Still Building Reports Manually?

Watch how growth teams are getting answers in seconds — not days.

Watch Graphed demo video

Step-by-Step Guide: Setting Up User-ID in GA4

Ready to implement it? We'll focus on the most popular and flexible method: using Google Tag Manager (GTM).

Before You Begin: What You'll Need

The core requirement for User-ID tracking is a system that generates a unique, persistent, and non-personally identifiable ID for each user when they sign up or log in.

  • Good Examples: A randomly generated ID from your user database (e.g., 1138249-ABC), a CRM contact ID, or a hashed user identifier.
  • Bad Examples (Never Use These): Email addresses, usernames, real names, or phone numbers. Sending Personally Identifiable Information (PII) to Google Analytics is a direct violation of their terms of service.

You also need access to your website’s source code (or a developer who has access) and administrator access to your Google Tag Manager container.

Step 1: Update Your Reporting Identity in GA4

First, you need to tell GA4 to prioritize the User-ID in its reports.

  1. In your Google Analytics account, go to Admin (the gear icon bottom-left).
  2. In the Property column, click on Reporting Identity.
  3. Select the Observed option. This tells GA4 to build its reports starting with User-ID first, then Google Signals, then Client ID. It's the cleanest and most straightforward approach.
  4. Click Save.

Step 2: Send the User-ID from Your Website to GTM

This is where your developer comes in. When a user successfully logs in to your site, you need to push their unique ID into GTM's data layer. The data layer is a JavaScript object that acts as a message bus between your website and GTM.

Ask your developer to add the following JavaScript snippet to run after a user has successfully logged in and their ID is available:

<script>
window.dataLayer = window.dataLayer || [],
window.dataLayer.push({
  'event': 'login_success',
  'user_id': '[USER_ID_FROM_YOUR_SYSTEM]' // This part must be dynamically replaced
}),
</script>

It's crucial that [USER_ID_FROM_YOUR_SYSTEM] is dynamically replaced by your website's back-end with the actual, unique ID of the logged-in user.

Step 3: Create a Variable in GTM to Capture the User-ID

Now, over in Google Tag Manager, you need to create a variable that listens for this user_id and stores its value.

  1. In your GTM container, navigate to Variables from the left-hand menu.
  2. Under the “User-Defined Variables” section, click New.
  3. Name your variable something descriptive, like dlv_user_id.
  4. Click Variable Configuration and choose Data Layer Variable as the variable type.
  5. In the “Data Layer Variable Name” field, enter user_id. This must exactly match the key name you used in the data layer snippet from Step 2.
  6. Leave the other settings as default and click Save.

You’ve now told GTM how to grab the user ID whenever it appears in the data layer.

GraphedGraphed

Still Building Reports Manually?

Watch how growth teams are getting answers in seconds — not days.

Watch Graphed demo video

Step 4: Configure Your GA4 Tag to Send the User-ID

The final step is to modify your main GA4 configuration tag to pass this new User-ID variable to Google Analytics.

  1. In GTM, navigate to Tags and click on your main Google Analytics: GA4 Configuration tag.
  2. Click into the Tag Configuration section.
  3. Find the Fields to Set accordion and expand it. Click Add Row.
  4. In the "Field Name" column, type user_id.
  5. In the "Value" column, click the Lego block icon (the variable selector). Find and choose the {{dlv_user_id}} variable you created in the last step.
  6. Save the tag.
  7. Finally, click the blue Submit button in the top right corner of GTM to publish your changes. Give your new version a name and description, then click Publish.

And that's it! Your setup is now live.

How to Verify Your User-ID Setup is Working

Don't just assume it's working, take a few minutes to verify it. Verification is easy with GTM's built-in tools.

Using GTM's Preview Mode

This is the fastest way to check your work.

  1. In your GTM workspace, click Preview in the top-right corner.
  2. Enter your website's URL and click Connect. A new tab with your website will open, with the GTM debugger connected at the bottom.
  3. On your website, go through your login process.
  4. In the debugger summary on the left, you should see the login_success event appear. Click on it.
  5. Now, click on the GA4 Configuration tag that fired on this event.
  6. Look at the details. You should see the user_id field listed, populated with the correct (non-PII) ID you logged in with. If you see it there, you've successfully sent the data from GTM.

Using GA4's DebugView

This confirms that Google Analytics is actually receiving and processing the User-ID.

  1. While you still have GTM Preview mode running, navigate to your GA4 account.
  2. Go to Admin > DebugView.
  3. On your website, refresh a page or navigate to a new one.
  4. You should see events streaming into the DebugView from your device. Click on one of these events, like page_view.
  5. Look in the "Parameters" list. You should see a user_id parameter displayed with the value you logged in with. This is your final confirmation!

Note: It can take 24-48 hours for User-ID data to begin appearing in your standard GA4 reports. After a day or two, you can verify this by going to Explore, creating a new report, and adding User ID as a dimension to see if the values are populating.

Final Thoughts

Implementing User-ID tracking is a transformative step that elevates your Google Analytics property from a simple traffic counter to a serious user analysis tool. By doing this, you unlock an accurate user count, understand the complete customer journey across devices, and lay the foundation for smarter, more effective marketing strategies.

Once you’ve connected powerful data sources like Google Analytics, the next step is turning that raw data into business answers. At Graphed, we automate the hard work of analysis. We make it easy to instantly build dashboards and get insights simply by asking questions in plain English. Instead of spending hours digging through reports to understand user behavior, you can just ask, "Show me the journey for users who converted from our latest campaign," and get an answer in seconds.

Related Articles

How to Enable Data Analysis in Excel

Enable Excel's hidden data analysis tools with our step-by-step guide. Uncover trends, make forecasts, and turn raw numbers into actionable insights today!