Analytics and Tracking

User ID

Also called user_id

Your own identifier for a signed-in customer, sent to analytics so the same person is recognised across devices and visits.

Quick facts: User ID

Category
Analytics and Tracking
Also called
user_id
Level
Advanced
Affects
User counts, cross-device journeys, retention and lifetime value reports, UK GDPR compliance
Where to see it
GA4 DebugView, GA4 reporting identity settings, Google Tag Manager, your site's login system
In this article4
  1. How User ID works
  2. Why it matters
  3. Common mistakes
  4. How to act on it

A User ID is your own identifier for a signed-in customer, sent to analytics tools such as GA4 so that the same person is recognised across devices and visits. Instead of a laptop and a phone counting as two users, GA4 can join their activity under one ID when the customer logs in on both.

How User ID works

When a customer logs in, your website or app passes a reference for their account, usually an internal database number, to the analytics tag as the user_id field. GA4 stores it alongside the client ID held in the browser’s cookie. Where the same user_id appears on several devices, GA4’s reporting identity can treat them as one user; the default blended identity gives the User ID priority over device identifiers.

The ID only applies while GA4 is told it, so you send it with every page view and event once the customer is signed in, and stop sending it when they log out. Visits on a new device before the customer logs in are still counted against that device.

Other platforms have their own versions. Meta accepts an external ID with Conversions API events, and CRMs and customer data platforms use their own keys. The principle is the same: a stable reference that your business controls.

Why it matters

For businesses where customers log in, such as online shops with accounts, subscription services, member portals and software products, a User ID gives a truer picture of loyalty and journeys. Someone who browses on a phone on the train and buys on a desktop at home becomes one journey instead of two strangers. Retention, cohort and lifetime value analysis all become more accurate.

Under UK GDPR, a User ID is personal data. It is pseudonymous, which lowers the risk, but because your business can link it back to a named account, the rules still apply: you need a lawful basis, your privacy notice must cover it, and the GA4 tag that sends it sets analytics cookies, which need consent under PECR.

Google’s Analytics terms also forbid sending information Google could use to identify a person, so the ID itself must never be an email address, a name or a phone number.

Common mistakes

  • Using the customer’s email address as the ID, which breaks Google’s policy and puts readable personal data in your analytics.
  • Sending a hashed email instead and assuming that solves it. A hash can still be matched to the address, so use an internal number.
  • Sending the same placeholder, such as “guest” or “0”, for logged-out visitors, which merges thousands of people into one user.
  • Carrying on sending the ID after logout, so everyone using a shared family computer is attributed to one account.
  • Expecting User ID to join up visitors who never log in. It cannot.

How to act on it

Only set it up if a meaningful share of your customers sign in. If they do, ask your developer to push the account’s internal reference into the data layer on login, map it to user_id in your GA4 tag and send nothing for logged-out visitors. Check it in DebugView, then confirm a few days later that user counts in your reports look plausible.

Record the ID in your records of processing and your privacy notice, and make sure your deletion process can remove a person’s analytics data by their ID when they ask; GA4 supports deleting data for an individual user. Planning measurement around what your business actually needs is part of the digital marketing strategy work I do.

Do and do not

Do

  • Use an internal account number as the ID
  • Send the ID only while the customer is signed in and has consented
  • Cover it in your privacy notice and deletion process

Do not

  • Use an email address or a hash of one as the ID
  • Send a placeholder value for logged-out visitors
  • Expect it to work for visitors who never log in

Questions people ask about this

Do I need consent to use User ID in GA4?

The User ID is sent by the GA4 tag, which sets analytics cookies that need consent under PECR in the UK, so in practice yes: only send it for visitors who accepted analytics cookies. You also need a lawful basis under UK GDPR and a clear explanation in your privacy notice. Logging in does not by itself count as consent to analytics.

Can I use User ID without a login system?

Not meaningfully. The ID has to come from something that reliably identifies the same customer each time, which in practice means an account login. Without one, GA4 relies on its client ID cookie and any modelling, so the same person on two devices remains two users.

What is the difference between User ID and client ID?

The client ID is created automatically by GA4 and stored in a cookie, so it identifies a browser on one device. The User ID is created by your business and identifies a signed-in account, so it can follow a person across devices. GA4 uses the User ID first when both are present.

Related terms

Found this useful?

Share it, or ask an AI to summarise it

Back to the glossary

Knowing the term is the easy part

Applying it to your own site and budget is the work. Book a call and I will tell you what actually applies to you.