Skip to content
FunnelGuard

Fix guide by FunnelsGuard

GA4 user_id set to an email address: how to find and fix it

TRK-025High impactDetectedBy FunnelGuardPublished Updated
On this page

What this issue is

GA4 has a user_id setting. It lets you recognise the same logged-in person across devices. The value should be an ID that means nothing outside your own systems, such as cust_48213.

This issue happens when the value is an email address like jane@example.com. It often comes from a login plugin, a GTM variable that reads the account email, or a developer who used the email because it was the easiest unique field. An email is personally identifiable information (PII): data that points to a real person.

The same problem can also appear in other places, such as an email in a page URL (/thanks?email=jane@example.com), in an event parameter, or in a user property. This guide focuses on user_id, but the check and the cleanup apply to all of them.

Why it costs you leads or sales

It rarely breaks a form on the day. The cost shows up later and is larger when it does.

What can go wrong
  • Google can ask you to remove the data, or can delete data that breaks its policy, which leaves holes in your reports.
  • Customers' emails sit in a third-party tool, which creates privacy and data protection risk (for example under GDPR) and can mean a breach you must handle.
  • Emails can flow on to linked tools, such as Google Ads audiences and BigQuery exports, and spread the problem.
  • Cleaning up later is slower: you cannot edit old hits, so the bad data stays until it expires or is deleted.
  • Fixing it in a hurry can break your user_id tracking, so cross-device reporting drops out until it is rebuilt.
How an email travels into GA4
  1. Visitor logs inAccount email is available in the page or data layer
  2. Tag reads the emailGTM variable or script sets user_id to the email
  3. Hit sent to GA4Request carries up=jane@example.com
  4. Reports and exportsEmail stored in Google's systems and linked tools

The email leaves your site at the tag step. Everything after that holds personal data.

How to check if your site has it

Check by hand in about 10 minutes
  1. Open a logged-in page

    Log in to your site with a test account that uses a fake email you control, for example test+ga4@yourdomain.com.

  2. Open the browser Network tab

    In Chrome, press F12, choose Network, and filter by collect. Reload the page.

  3. Inspect the GA4 requests

    Click a request to google-analytics.com/g/collect. In the Payload or Query String Parameters, look for uid. Also search the whole request for @ and for your test email.

  4. Check GTM Preview modeGoogle Tag Manager

    If you use Google Tag Manager, open Preview, select your GA4 tag and look at the Fields to Set and Configuration settings for user_id. Open the Variables tab and see what value the variable holds.

  5. Check GA4 DebugView

    In GA4, go to Admin > DebugView, and click an event. Look under User properties and event parameters for an email.

  6. Check URLs too

    Look at the dl parameter (page location) in the request. If a query string contains an email, that is PII in the URL too.

What a bad GA4 request can look like (example)text
https://www.google-analytics.com/g/collect?v=2&tid=G-XXXXXXX&en=page_view&uid=jane%40example.com&dl=https%3A%2F%2Fexample.com%2Faccount

How to fix it

The fix has two parts: stop sending the email, then send a safe ID instead. Pick the safe ID first, because your developer or platform needs a value to use.

Which value to use as user_id
OptionSafe?Notes
Internal customer or database IDYesBest choice. Meaningless outside your systems.
Random ID (UUID) stored on the accountYesGood if you have no customer number.
Email addressNoThis is the problem. Remove it.
Plain hash of the email (for example SHA-256)RiskyCan be matched against known emails. Avoid it for user_id.
Replace the email with a safe ID
  1. Find the variable

    In GTM go to Variables and find the one used for user_id. Check your GA4 tag's Fields to Set, or the Google tag's Configuration settings, for the field user_id.

  2. Change its source

    Point it at a data layer variable that holds the internal ID (for example customer_id), not the email.

  3. Test in Preview

    Run Preview, log in with the test account and confirm the variable shows the new ID. Then publish a new container version.

WordPress: send the numeric user ID, not the emailphp
<?php
add_action('wp_head', function () {
  if (is_user_logged_in()) {
    $id = get_current_user_id();
    echo "<script>window.dataLayer=window.dataLayer||[];dataLayer.push({'customer_id':'" . esc_js($id) . "'});</script>";
  }
});
Shopify theme: use the customer IDliquid
{% if customer %}
<script>
  window.dataLayer = window.dataLayer || [];
  dataLayer.push({ 'customer_id': '{{ customer.id }}' });
</script>
{% endif %}
gtag.js: set a safe user_idjavascript
// BAD: gtag('config', 'G-XXXXXXX', { user_id: 'jane@example.com' });
// GOOD:
gtag('config', 'G-XXXXXXX', { user_id: 'cust_48213' });
Clean up after the code fix
  1. Remove emails from URLs and parameters

    Stop forms from redirecting to URLs that contain an email. Use POST or a session instead of query strings.

  2. Review other fields

    Check event parameters and user properties for emails, names or phone numbers too.

  3. Deal with data already collected

    Old hits cannot be edited. In GA4, see Admin > Data collection and modification > Data deletion requests to ask for removal of the affected data. Involve your privacy lead or data protection officer, as you may have to document the incident.

  4. Tell connected tools

    If GA4 feeds BigQuery or Google Ads, check those places for the email too.

user_id before and after the fix

Before

  • user_id is jane@example.com
  • Email visible in the request and DebugView
  • Breaks Google's PII policy

After

  • user_id is cust_48213
  • No @ sign in any GA4 request
  • Cross-device reporting still works
Where the email leaks

The tag passes account data on to Google when it should pass a safe ID.

How to confirm it's fixed

Confirmation checks
  • Log in with the test account, reload, and filter the Network tab by collect. No request contains @ or the test email.
  • The uid value is your internal ID.
  • GTM Preview shows the user_id variable holding the safe ID.
  • DebugView shows no email in user properties or event parameters.
  • The dl page location has no email in the query string.
  • Log out and check that uid is gone.
  • Test on mobile and in a private window, as cached pages can keep sending the old value.

How to prevent it happening again

Prevention habits
  • Write down which ID is allowed as user_id and share it with developers and agencies.
  • Review GTM changes before publishing, especially variables that read account or form data.
  • Never put form values in URLs. Use POST or a session.
  • Test after every theme, plugin or login-system change.
  • Add a PII check to your launch checklist for new sites and funnels.
  • Re-check regularly, because a plugin update can bring the problem back.

How FunnelGuard handles this

FunnelGuard detects this issue today. Its robot visitor runs your real journeys on a schedule and runs a no_pii_in_tracking check on the tracking hits it captures along the way. If a hit contains personal data such as an email address, the check fails.

A failure is re-checked from a second region before one alert is sent, with a screenshot and a likely cause. You can get it by email, Slack, Teams, WhatsApp, webhook or PagerDuty.

What this means in practice: the robot can only see what its own test journeys send. It does not search the data already stored in your GA4 property, so you still need to handle old hits yourself. FunnelGuard marks its test traffic (utm_source=funnelguard, fg_test=1, an fg_test cookie and its own user agent) and never enters real card details. The Free plan covers 1 site and 2 journeys with daily checks and no card, and paid plans have a 3-day free trial. A free read-only website audit is also available.

Questions people ask

Can I use an email address as the GA4 user_id?

No. Google's Analytics policies prohibit sending personally identifiable information such as email addresses. Use an internal customer ID or a random ID that cannot be traced back to a person outside your own systems.

Is a hashed email OK as a GA4 user_id?

It is safer than a plain email but still risky. A simple hash such as SHA-256 of an email can be matched against known addresses, so it may still count as personal data. An internal ID or random UUID is the better choice.

How do I check if my GA4 is sending emails?

Open the Network tab in Chrome, filter by collect and look at the GA4 requests on a logged-in page. Search for uid and the @ sign. You can also check DebugView in GA4 and the Preview mode in Google Tag Manager.

What happens if GA4 collects email addresses?

Google can ask you to remove the data or can delete data that breaks its policy. You may also have a privacy issue under laws like GDPR. Fix the source, then request deletion of the affected data.

How do I delete emails that GA4 already collected?

You cannot edit old hits. In GA4 go to Admin > Data collection and modification > Data deletion requests to ask for removal. Speak to your privacy lead about whether you need to record or report the incident.

Why is there an email in my GA4 page URLs?

A form or login probably redirects to a URL with the email in the query string, such as /thanks?email=.... GA4 records the page URL, so it records the email. Change the form to use POST or a session, and stop passing personal data in links.

Will changing user_id break my GA4 reports?

Reports based on the old values will not join up with the new IDs, so cross-device matching restarts. This is a small cost compared with keeping personal data in Google's systems. Use a stable internal ID from now on so it does not change again.

Can FunnelGuard tell me if GA4 is getting an email?

Yes, for the journeys it runs. Its no_pii_in_tracking check looks at the tracking hits captured during the test and fails if one contains personal data like an email. It does not scan data already stored in GA4.

Does FunnelGuard catch this?

Detected

FunnelGuard checks for this today.

How: no_pii_in_tracking.

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.