← All Guides

GA4 User ID and User Properties: Cross-Device Measurement for Logged-In Users Without Breaking Privacy

How to send a User ID and user properties to GA4 through GTM when visitors log in, what it changes in reporting identity and cross-device journeys, the rules on what the ID may and may not be, how to keep it out of URLs, and how to use it with BigQuery and audiences.

Atiqul Islam
Written by Atiqul Islam

Tracking & analytics specialist. 278+ GTM, GA4 and server-side tracking projects for clients in the US, UK and Australia.

Rather not do this yourself? I set this up for clients every week. Free 15-minute audit, no obligation.

Book a Free Audit

Most of your visitors are anonymous, and GA4 identifies them by a cookie per browser. For the visitors who log in, you know more: they are the same person on their phone, their laptop and the office computer. The User ID feature lets GA4 use that knowledge. This guide covers the setup through GTM, the rules, and what it unlocks.

What the User ID Does

When you send a user_id with events, GA4 can link sessions from different devices and browsers that share the same ID, provided the reporting identity includes User ID. User counts become closer to real people, cross-device paths appear, and audiences can include a person on every device they used while logged in.

It does not retroactively link anonymous sessions before login, except within the same browser where GA4 can associate the earlier client ID with the user once the ID appears.

The Rules

A database primary key such as 48213, or a SHA-256 hash of it, is ideal.

Step 1: Push the ID and Properties When Known

On every page where the user is logged in, before the GTM snippet:

<script>
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
  user_id: '48213',
  user_plan: 'pro',
  user_customer_status: 'existing',
  user_orders_band: '5-10',
  user_signup_year: '2024'
});
</script>

On single page apps, push the same keys when the login completes and send a login event, then ensure subsequent virtual page views carry them.

Push user_id as an empty value on logout so GTM does not keep sending the previous user's ID on that browser.

Step 2: Configure the Google Tag

In GTM, open the Google tag. Under Configuration settings, add user_id with value {{dlv - user_id}}. Under Shared event settings or User properties, add each property: plan to {{dlv - user_plan}}, customer_status to {{dlv - user_customer_status}}, orders_band to {{dlv - user_orders_band}}.

GA4 ignores an undefined user_id, so anonymous visitors are unaffected.

Step 3: Reporting Identity

In GA4 Admin, Property settings, Reporting identity, choose Blended, which uses User ID, then Google Signals if on, then device ID, then modelling. Observed is the same without modelling. Device-based ignores User ID entirely.

Step 4: Register User Properties

Under Admin, Custom definitions, create user-scoped custom dimensions for each property: Plan from plan, Customer status from customer_status, and so on. You have 25 user-scoped dimensions.

Step 5: Use It

Cross-Device in Practice

A user reads guides on a phone while logged in, then signs up for a plan on a laptop the next day, also logged in. With User ID and Blended identity, GA4 reports one user, a two-session journey, and attributes the purchase to the phone session's campaign under data-driven attribution. Without it, two users, two journeys, and the purchase attributed to the laptop's direct visit.

Keeping It Out of URLs

Some apps put the user ID in query strings or paths, for example /account/48213. GA4 would store that in page_location, which is acceptable for an opaque ID but not for emails. If your URLs contain emails or names, use a GTM variable to redact them from page_location before the Google tag sends it, or change the URL structure.

Testing

  1. Log in on the site with GTM Preview open. Confirm the Google tag's configuration shows user_id and the user properties populated.
  2. GA4 DebugView: select your device; events show a user ID in the header and the user properties in the panel.
  3. Log out; confirm user_id is empty on subsequent events.
  4. After a day, the User explorer shows your test user with sessions from two devices if you repeated the login elsewhere.

Common Mistakes

Outcome

Logged-in customers become one person across their devices in GA4, with attributes you can segment and target by, and a clean join key to your own data in BigQuery, all without putting anyone's identity into analytics.

Frequently Asked Questions

What can I use as the User ID?

An internal identifier that is not personally identifiable on its own: your database user ID or a hashed version of it. Never an email address, name, phone number or anything that reveals who the person is. Google's terms prohibit it and it creates a privacy liability.

What does User ID change in reports?

With reporting identity set to Blended or Observed, GA4 uses the User ID to unify sessions from the same person across devices and browsers, so one customer who researched on a phone and bought on a laptop is one user. Without it, they are two.

Do I need consent to send a User ID?

Treat it as analytics data under your consent setup. If analytics storage is denied, do not send it. The ID is pseudonymous, but it links behaviour to an account, so your privacy policy should mention it.

What are user properties for?

Attributes of the person that should apply to every event: plan, customer status, account type, lifetime orders band. Register them as user-scoped custom dimensions to use them in reports and audiences.

Can I send User ID for anonymous visitors?

No. Only send it when you actually know who the user is, typically after login. Before that, GA4 uses the client ID. Sending a placeholder ID for everyone would merge unrelated people.

Want This Done Right the First Time?

Book a free 15-minute audit call. I'll review your setup, show you what is broken, and tell you exactly what it takes to fix it.

Chat Now