Skip to content
FunnelGuard

Fix guide by FunnelsGuard

dataLayer contains PII (email, phone): how to find and fix it

TRK-133High impactPartlyBy FunnelGuardPublished Updated
On this page

What this issue is

The dataLayer is a JavaScript list (window.dataLayer) that your site uses to pass information to Google Tag Manager (GTM). Developers push things like the page type, product ID or order value into it. PII (personally identifiable information) means data that identifies a person: an email address, phone number, full name, home address or similar.

Example of a risky pushjavascript
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
  event: 'lead_form_submit',
  user_email: 'jane@example.com',
  user_phone: '+441234567890'
});

Why it costs you leads or sales

Google Analytics terms forbid sending personal data to GA4, and other ad platforms have similar rules. If a tag forwards an email as an event parameter, the platform may delete the data, flag the property, or restrict features. Privacy laws such as GDPR and CCPA also apply, so unplanned sharing can create legal exposure and force you to pause tracking while you clean up.

How PII leaks from a form to ad platforms
  1. Visitor submits formEnters email and phone
  2. Script pushes to dataLayerEmail sent as plain text
  3. GTM tags read variablesAny tag can use the value
  4. Platforms receive PIIGA4, Ads, Meta hits contain it

The break is the plain-text push; everything after it carries personal data.

Data flowing where it should not

Personal data moves from the page into tags and out to platforms.

How to check if your site has it

Find PII in the dataLayer and in outgoing hits
  1. Inspect the dataLayer in the browser

    Open your site, open DevTools, go to Console and type dataLayer. Submit a test form with a fake address such as test@example.com, then look for that address in the list.

  2. Use GTM Preview modeGoogle Tag Manager

    In GTM click Preview, load your site, submit the form and open the Data Layer tab for each event. Check every key and value for emails, phones or names.

  3. Check the network hits

    In DevTools open Network, filter for collect, facebook.com/tr or googleads, submit the test form and search the request URLs and payloads for your fake email or phone.

  4. Review variables and tagsGoogle Tag Manager

    In GTM go to Variables and look for Data Layer Variables named email, phone, name or address. Check which tags use them in Tags > each tag's fields.

  5. Check URLs too

    Look at thank-you page URLs and query strings. Addresses like ?email=jane@example.com are also picked up by page_location.

How to fix it

Decide first what each platform actually needs. Most conversion tracking needs only an event name, a value and an ID. If you use Google Ads enhanced conversions or Meta advanced matching, the platform expects user data, but it should be sent through that feature (which hashes it), not as a custom parameter.

Remove or protect PII by platform
  1. Remove the fields from the push

    Delete user_email and user_phone from the dataLayer.push call, keeping only event name and non-personal values.

  2. Hash if a platform needs it

    If you need to pass an email for matching, hash it with SHA-256 after trimming and lowercasing, and send it only to the tag that requires it.

Safer push: no personal datajavascript
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
  event: 'lead_form_submit',
  form_id: 'contact_main',
  lead_type: 'quote_request'
});
dataLayer push before and after

Before

  • Email and phone pushed in plain text
  • Any tag can read and send them
  • Platform may reject or flag data

After

  • Only event name and non-personal IDs
  • User data sent only through hashing features
  • Hits contain no readable personal data

How to confirm it's fixed

Confirmation checks
  • Submit a test form with a fake email and phone, then search the dataLayer in the Console for them: no matches
  • GTM Preview Data Layer tab shows no email, phone or name values
  • Network requests to GA4, Google Ads, Meta and others contain no readable test email or phone
  • Thank-you page URL has no personal data in the query string
  • GA4 DebugView events show no PII parameters
  • Enhanced conversions diagnostics in Google Ads show hashed data only, if you use it

How to prevent it happening again

Prevention habits
  • Keep a written data-layer spec listing allowed keys; no personal fields
  • Review every new form, plugin or tag in GTM Preview before publishing
  • Limit who can publish GTM changes and add a note to each version
  • Never put personal data in URLs or query strings
  • Re-test key forms after redesigns, plugin updates and agency changes
  • Tie any user-data sending to your consent setup

How FunnelGuard handles this

FunnelGuard covers this issue partly. Its no_pii_in_tracking check looks at the tracking hits your funnel sends to ad and analytics platforms during a scheduled test journey, and flags personal data it finds in those hits. It does not read your dataLayer directly, so a plain-text email that sits in the dataLayer but is never sent in a hit is not reported.

Questions people ask

What is PII in the dataLayer?

It is personal data such as an email address, phone number or name stored in the dataLayer list that Google Tag Manager reads. Once it is there, any tag can use it and send it to platforms like GA4, Google Ads or Meta.

How do I check if my dataLayer contains an email address?

Open your site, type dataLayer in the browser Console, and submit a form with a fake email. Also use GTM Preview and its Data Layer tab. Search for your test email in both and in the Network tab hits.

Is it allowed to send emails to Google Analytics?

No. Google Analytics terms prohibit sending personally identifiable information to GA4. If it happens, the data may be deleted and the property may be restricted, so remove it from tags and events.

Can I send hashed emails to Google Ads or Meta?

Yes, through features built for it, such as Google Ads enhanced conversions or Meta advanced matching. Trim and lowercase the value, hash it with SHA-256, and only send it with the right consent. Hashed data is still treated as personal data in many regions.

How do I remove PII from the dataLayer in GTM?

Remove the personal fields from the dataLayer.push code, stop tags using the related Data Layer Variables, and delete variables you no longer need. Then test in Preview mode and check network hits.

Why is there an email in my GA4 page URL?

A form or thank-you redirect probably adds it as a query string such as ?email=. GA4 records page_location, so the email is stored. Change the form to use POST or a session ID, and remove the parameter.

Does FunnelGuard detect PII in my dataLayer?

Only partly. FunnelGuard's no_pii_in_tracking check inspects the tracking hits sent during test journeys, not the dataLayer itself. You should still inspect the dataLayer by hand.

Does FunnelGuard catch this?

Partly

FunnelGuard checks part of this.

How: no_pii_in_tracking checks hits.

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.