Begin with a decision that needs identity
GA4 User-ID is for businesses that already authenticate customers and have a reason to understand activity across sessions or devices. Google describes it as a business-assigned, persistent identifier for signed-in users. A tutoring service might ask whether members who first browse on a phone later complete a booking on a laptop. A shop might examine repeat purchasing journeys after login. Neither example requires identifying a person in a public report. If most visitors never sign in, or the team only needs page-level demand and completed orders, a User-ID project may add engineering and privacy work without changing a useful decision. Write the question and the intended action before adding the tag setting.
User-ID is not a way to make every anonymous session identifiable. Google's reporting identity can use User-ID together with device identity and, for a blended option, modeling. Collection before the feature was implemented is not reprocessed into historical User-IDs. Google also explains that some activity before a user signs in during a session may be associated with the later ID, while subsequent activity after sign-out is no longer associated once the ID is cleared. These behaviours make a boundary test essential. Do not tell management that a new User-ID field will reconstruct every earlier visit or reveal every customer's full journey. State which journeys were actually measurable during the chosen period.
Choose a stable non-identifying value
Google requires each real user to receive a unique, consistent User-ID of no more than 256 characters. The value must not itself contain information that a third party could use to determine a person's identity. Use an internal opaque account key with a documented lifecycle. Do not send a name, email address, phone number or a shared placeholder such as guest or 0. Hashing an email does not automatically solve the policy or re-identification problem, so avoid treating an email-derived string as the easy default. Ask the developer which identifier is sent, when it is created, whether it can be reassigned, and whether one person can have several accounts. Review the privacy notice and consent choices for the measurement you actually perform.
The operational danger of a dummy value is measurable: if unrelated visitors all send the same nonempty string, GA4 interprets them as one user ID. That can distort user counts and combined journeys. Equally, assigning a new ID on every page view defeats the goal of connecting sessions. An account merge, deletion or reassignment policy should be considered before release; otherwise an old ID might accidentally describe a different person later. Record only a synthetic test key in the implementation checklist, never a real customer's identifier. Limit access to raw export data because an opaque key can still become sensitive when combined with business records.
Handle three sign-in states separately
Google's developer guidance distinguishes three states. If someone has never signed in, omit the user_id parameter. If the person is signed in, send that account's stable ID. If the person signed in and then signed out, explicitly set user_id to the JavaScript null value. A blank string, the quoted word null or a common guest value is not a substitute. The distinction matters on a single-page app where the analytics configuration may persist after the visible account menu says Signed out. Test the actual event stream after logout, not only the button label. Clear the old value before another household member signs into the same browser.
Google says the value belongs in the tag configuration or set command, not a custom user property, ordinary event parameter or registered custom dimension. When an account becomes known after the tag first loads, the developer guide recommends gtag set so subsequent events use the new value. On later page loads, the signed-in state should be applied consistently. If the site uses Tag Manager instead of direct gtag code, map the same lifecycle into its tag configuration and test the released container. Do not assume a data-layer variable called user_id is enough; verify what the Google tag sends under each state. If consent prevents Analytics collection, the ID plan must respect that boundary as well.
Test real transitions with synthetic accounts
Build a small test matrix rather than checking one successful login. Visit a page as a fresh guest; sign in as synthetic account A; navigate to a second page; sign out; generate another page view; then sign in as synthetic account B in the same browser. Repeat on a second device if cross-device measurement is the business reason. Inspect requests or tag diagnostics to confirm that guest activity lacks a User-ID, A's events use A's key, post-logout events do not retain it, and B's events use B's key. Include a failed login, expired session and back-button route if they occur in the actual product. Do not log real IDs in a public bug tracker.
After the event-level checks, verify the GA4 property setting. Google says Reporting Identity must include User-ID; its current choices include Blended, which evaluates user and device IDs with modeled data, and Observed, which evaluates user and device IDs. Changing this setting requires the appropriate property role. Compare signed-in and other activity in reports only after enough actual collection has occurred. A test request proves the field was sent, not that cross-device reporting or business attribution is complete. If Analytics is linked to BigQuery, Google notes that User-ID can be present in exported data regardless of a user's consent status, so review export access and consent design before enabling the feature.
Use the result within its limits
Imagine a retailer testing whether saved baskets help returning members finish orders. The team could compare signed-in journeys before and after a basket improvement, with the same order definition and a stable observation period. It should also record whether the proportion of visitors who sign in changed, whether a new promotion ran, and whether checkout errors occurred. User-ID may reduce some device fragmentation for signed-in users; it does not make a before-and-after comparison causal, and it says little about guests. A practical decision might be to fix a persistent saved-basket error found in the observed journey, then verify actual completed orders in the commerce system.
Keep the distinction between User-ID and user-provided data clear. Google describes User-ID as the site's own non-personally-identifying key for signed-in users; its separate user-provided-data features have different purposes and conditions. Do not enable extra data collection merely because an analytics screen offers it. For a small business, the durable outcome is a documented decision: which users are eligible for a key, what the tag sends at each state, who can access exports, what reports may be compared, and when to retire the implementation if it no longer supports a useful decision. Revisit the policy and configuration whenever the login journey or consent flow changes.
Before release, assign responsibility for two separate failures. An engineering owner should catch stale IDs, shared placeholders and tag values that survive logout. An analytics owner should catch reports that combine unlike populations or interpret a signed-in comparison as all customers. Document how test accounts are removed from routine analysis and how a real customer can use the site's ordinary privacy controls. Review any BigQuery access as part of the same launch because raw identifiers can be joined with other records even when the GA4 interface does not show them in standard reports. If the sign-in product changes, rerun the transition matrix rather than assuming the old tag logic still follows the new flow. Set a review date to ask whether the implementation has produced a useful decision. If it has not, simplify the measurement instead of collecting an identifier indefinitely. A good outcome is a trustworthy answer about eligible signed-in journeys and a clear statement of the guest and consent-related gaps, with no promise of identifying every visitor.
Before you proceed
- Is there a signed-in cross-device question that changes a real decision?
- Does each account use a stable opaque ID while guests send none and logout clears it?
- Were both tag requests and reporting identity checked with synthetic accounts?


