Skip to content
FunnelGuard

Fix guide by FunnelsGuard

GA4 user_id set to a constant value: how to find and fix it

TRK-026Medium impactCould addBy FunnelGuardPublished Updated
On this page

What this issue is

user_id is a GA4 field you set yourself. It lets GA4 recognise the same person across devices and sessions once they sign in. GA4 trusts whatever you send. It does not check that the value is unique.

This issue happens when every visitor gets the same value. Common causes: a hardcoded test ID left in the code, a Google Tag Manager variable that returns undefined, null or 0 as text, a template tag that was never filled in (such as {{user.id}} printed literally), or a CRM or form variable that falls back to a default.

Why it costs you leads or sales

With one ID shared by everyone, GA4 sees one very busy person. User counts shrink, and journeys from different people are stitched into one path. Funnel and path reports stop reflecting real behaviour, and the conversion rate per user looks wrong.

That feeds bad decisions. You may cut a campaign that works, because its users look like repeat visitors who already converted. Audiences built on this data (for remarketing, for example) can also be wrong. The impact is medium: leads are not lost directly, but the numbers you steer by are.

Reported users vs real visitorsExample numbers
Reported users vs real visitors (example)Real signed-in visitors: 5,000 users; Users in GA4 reports: 1 users01,9173,8335,0001Real signed-in visito…Users in GA4 reportsusers

Example: 5,000 signed-in visitors in a month. With a constant user_id, user-based reports can show a tiny fraction of that.

How a constant ID breaks user reporting
  1. Visitor A logs inuser_id = "undefined"
  2. Visitor B logs inuser_id = "undefined"
  3. GA4 merges themOne user, many devices
  4. ReportsUsers, funnels and paths are wrong

Every visitor is sent the same ID, so GA4 cannot tell them apart.

How to check if your site has it

Check what user_id your site sends
  1. Open GA4 DebugView

    In GA4 go to Admin > DebugView. Turn on debug with Google Tag Assistant or the GA debugger extension, then browse your site while signed in. Click an event and look at its user properties and the user_id.

  2. Test with two accounts

    Sign in as two different test users in two browsers. If both show the same user_id, you have the problem.

  3. Inspect the network request

    Open browser DevTools > Network, filter for collect, and click a GA4 request to google-analytics.com. Look for the uid parameter in the request. Check it differs per user and is not undefined, null, 0 or a placeholder.

  4. Check the reports

    In Reports > Explore, create a free-form report with User ID as a dimension. One value covering nearly all traffic is a red flag.

How to fix it

The fix has two parts: find where the value comes from, then make sure it is a real per-user ID that is only set after login. Use an internal ID such as a database user number, never an email address or name.

Fix the user_id by platform
  1. Find the source variable

    Open your GA4 Configuration tag (or Google tag) and look under Fields to Set or User Properties for user_id. Note which variable it uses.

  2. Fix the variable

    If it is a Constant variable, replace it with a Data Layer Variable (for example user.id) pushed by your site after login. If it is a JavaScript variable, make sure it returns the real ID.

  3. Skip empty values

    Add a trigger or condition so user_id is only set when the variable is not undefined and not empty. Use Preview mode to confirm.

Set user_id only for signed-in users (gtag.js)javascript
// Run after you know who the user is
function setGaUser(userId) {
  if (userId && String(userId) !== 'undefined' && String(userId) !== 'null') {
    gtag('config', 'G-XXXXXXXXXX', { user_id: String(userId) });
  }
}

// On logout
function clearGaUser() {
  gtag('set', { user_id: null });
}
Push the ID to the GTM data layer after loginjavascript
window.dataLayer = window.dataLayer || [];
dataLayer.push({
  event: 'login',
  user: { id: '48213' } // your internal user number, not an email
});
user_id before and after

Broken

  • Every visitor sends uid=undefined
  • GA4 shows one user for all signed-in traffic
  • Anonymous visitors also carry an ID

Fixed

  • Each signed-in user sends their own internal ID
  • Anonymous visitors send no uid
  • User counts match real people
What a constant user_id doesInteractive
Same user_id sent to everyone

Constant ID

Leads or data lost

GA4 merges all signed-in visitors into one user. User counts collapse and paths are mixed together.

Toggle the cause to see how user reports change.

How to confirm it's fixed

Confirmation checklist
  • Two different test accounts show two different user_id values in DebugView
  • The uid parameter in the collect request is a real ID, never undefined, null or a placeholder
  • Logged-out visitors send no uid
  • After logout, user_id is cleared
  • New data in Explore shows many User ID values, not one
  • Wait a day or two: old data stays wrong, only new data is clean

How to prevent it happening again

Prevention
  • Never hardcode a user_id, even for testing. Use a debug-only branch.
  • Use GTM Preview and DebugView with two accounts before publishing any analytics change
  • Only set user_id when a real value exists
  • Use an internal ID, not an email, name or phone number
  • Review user_id after theme, login plugin or membership tool updates
  • Keep a short change log of analytics edits

How FunnelGuard handles this

FunnelGuard does not check for this yet. Comparing user_id values across visitors is a possible future check, but today it is not part of the product.

What FunnelGuard does cover nearby: a robot visitor runs your real journeys on a schedule and checks that the GA4 tracking hits are sent at each step, so a missing or broken GA4 tag shows up. It does not inspect whether your user_id is unique, because the robot does not sign in as real users.

To watch for this manually, re-run the two-account DebugView test after each release, and add a monthly look at a User ID report in Explore. If one ID accounts for most traffic, investigate. You can start with the free plan (1 site, 2 journeys, daily checks) to keep the rest of your tracking monitored.

Questions people ask

Why does GA4 show only one user for all my traffic?

The most likely cause is a user_id that is the same for every visitor, such as a hardcoded value or the text "undefined". GA4 treats the same user_id as the same person. Check the uid parameter in the collect request and fix the variable that supplies it.

What should I use as a GA4 user_id?

Use a stable internal ID, such as a database user number, that is unique per person and carries no personal data. Do not use an email address, name or phone number. Send it only after the person has signed in.

How do I check what user_id GA4 is receiving?

Open Admin > DebugView in GA4 while browsing your site in debug mode and click an event to see the user_id. You can also open DevTools > Network, filter for collect, and read the uid parameter. Test with two different accounts.

Should I send a user_id for logged-out visitors?

No. Anonymous visitors should send no user_id at all. A default value for logged-out users makes them all look like one person.

Why is my GA4 user_id showing undefined or null?

The variable feeding user_id is returning no value when the tag fires, often because the data layer push happens after the tag, or the user is not signed in. Fix the timing or only set the ID when a real value exists.

Will fixing the user_id repair my old GA4 data?

No. GA4 does not rewrite past data, so earlier reports stay merged. Only data collected after the fix is accurate, so note the fix date.

Does FunnelGuard detect a constant GA4 user_id?

Not yet. It is a possible future check. FunnelGuard does check that GA4 tracking hits are sent during your journeys, but for user_id you need a manual test with DebugView.

Does FunnelGuard catch this?

Could add

Not checked yet: could be added to FunnelGuard.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.