Skip to content
FunnelGuard

Fix guide by FunnelsGuard

PII in dataLayer sent to all vendors: how to find and fix it

TRK-360High impactPartlyBy FunnelGuardPublished Updated
On this page

What this issue is

The dataLayer is a JavaScript array (window.dataLayer) that your site uses to pass information to Google Tag Manager (GTM) or other tag tools. Anything pushed into it becomes a value that any tag or variable in the container can read.

The problem starts when a developer, plugin or theme pushes raw personal data into it. Typical examples are a form plugin pushing the submitted email, a checkout pushing the full billing address, or a login event pushing the user's name. If a tag is set to send the whole dataLayer, or a variable is reused across tags, that data goes to every vendor, not just the one that needs it.

Example of a risky pushjavascript
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
  event: 'form_submit',
  form_id: 'contact',
  user_email: 'jane.doe@example.com',
  user_phone: '+44 7700 900123',
  user_name: 'Jane Doe'
});
How one push reaches many vendors
  1. Form submitPlugin pushes email and phone into dataLayer
  2. GTM containerAll tags can read the values
  3. GA4 and Google AdsReceive the PII as parameters
  4. Meta, TikTok, othersReceive the same PII

Raw PII in the dataLayer is available to every tag that fires on the event.

Why it costs you leads or sales

Sending personal data to ad and analytics vendors without a lawful basis or consent can breach privacy laws such as GDPR and CCPA, and breaks the terms of most platforms. Google Analytics, for example, forbids sending PII to it. The result is not just legal risk. The business effects are practical too.

What can go wrong when PII leaks through the dataLayer
ConsequenceWhat happens
Data deleted or blockedA platform may delete the affected data or suspend the property or account for policy breach, which damages reporting and campaigns.
Consent breachData goes to vendors before or without consent, which can lead to complaints and fines.
Lost trustCustomers who learn their email was shared with ad networks may stop buying or filling in forms.
Polluted audiencesUnplanned identifiers in ad platforms make audiences and reports hard to clean up.

How to check if your site has it

Find PII in your dataLayer
  1. Inspect the live dataLayer

    Open your site in Chrome, open DevTools, go to the Console and type dataLayer. Expand the entries and look for emails, phone numbers, names and addresses. Then submit your forms and run a test checkout, and look again.

  2. Use GTM Preview modeGoogle Tag Manager

    In Tag Manager click Preview, enter your URL and run the journey. In Tag Assistant, click each event and open the Data Layer tab to see what was pushed.

  3. Check which tags read itGoogle Tag Manager

    In Preview, open the Variables tab for each event. Note any variable holding PII and which tags use it.

  4. Inspect outgoing requests

    In DevTools open the Network tab and filter for collect, g/collect, tr and events. Look in the query string and payload for emails, phone numbers or names. Plain text or encoded values both count.

  5. Search your code and plugins

    Search your theme and plugin code for dataLayer.push and review which fields are included. Check form, checkout and membership plugins in particular.

How to fix it

The principle is simple: keep raw PII out of the dataLayer, and where a vendor needs a user identifier for matching, send it to that one vendor in the format it documents, only with the right consent.

Fix the leak
  1. Remove PII from the pushes

    Change the code, plugin setting or template that pushes the personal fields. Push non-identifying data instead, such as form_id, lead_type or an internal ID that cannot be traced to a person without your own database.

  2. Find tags that send the whole dataLayer

    Review each tag for custom parameters that map PII variables, and for settings that pass extra fields. Remove those mappings.

  3. Block PII with a sanitising variable or ruleGoogle Tag Manager

    As a safety net, use a Custom JavaScript variable or a GTM transformation to remove or mask fields before tags read them. Do not rely on this alone.

  4. Send identifiers only where the vendor asks for them

    If Meta or Google Ads needs customer data for matching, use that vendor's documented feature (for example enhanced conversions or Advanced Matching) in that tag only, and only when consent allows it.

  5. Gate tags on consent

    Make sure tags that handle identifiers only fire after the right consent signal is granted.

  6. Publish and clean up

    Publish the container, then check the vendors' own tools for stored PII and follow their deletion process where needed.

Where to change the push, by platform
  1. Check form and shop plugins

    Open the settings of your form plugin, WooCommerce or GTM plugin and look for options like 'include user data' or 'add customer data to dataLayer'. Turn them off.

  2. Search theme and child theme

    Search functions.php and plugin files for dataLayer.push and remove personal fields.

Allow-list helper for dataLayer pushesjavascript
var ALLOWED = ['event', 'form_id', 'lead_type', 'value', 'currency', 'transaction_id'];
function safePush(obj) {
  var clean = {};
  Object.keys(obj).forEach(function (k) {
    if (ALLOWED.indexOf(k) !== -1) clean[k] = obj[k];
  });
  window.dataLayer = window.dataLayer || [];
  window.dataLayer.push(clean);
}

safePush({ event: 'form_submit', form_id: 'contact', user_email: 'jane@example.com' });
// user_email is dropped
Push before and after the fix

Before

  • Push includes email, phone and name
  • Every tag can read those values
  • PII appears in GA4, Meta and other requests

After

  • Push has only form ID and event name
  • Tags receive no raw personal data
  • Vendor matching, if used, is set per tag with consent

How to confirm it's fixed

Confirmation checks
  • Console dataLayer shows no email, phone, name or address after a test form and checkout
  • GTM Preview shows no PII in any event's Data Layer tab
  • Network requests to GA4, Google Ads, Meta and others contain no test email or phone
  • Searching your vendor reports for the test email returns nothing
  • Tags that use identifiers fire only after consent is granted
  • A repeat test on mobile and in a private window gives the same result

How to prevent it happening again

Prevention habits
  • Keep a written data layer spec listing the allowed keys
  • Use an allow-list helper or GTM transformation as a safety net
  • Review plugin and theme updates for new tracking options
  • Review container changes before publishing and test in Preview
  • Repeat the Network tab check with a fake email after each release
  • Limit who can add custom HTML tags to the container

How FunnelGuard handles this

FunnelGuard detects this issue only partly. It runs your real journeys with a robot visitor and checks the tracking hits sent to platforms such as GA4, Google Ads, Meta, TikTok, LinkedIn, Bing, Pinterest, Snapchat, X and Reddit. That means it can show you whether the expected hits fire at each step, which is the evidence you need to start looking at what those requests contain.

What it does not do is inspect every dataLayer push for personal data or judge whether a value in a vendor request counts as PII. It also cannot see what a vendor stores after receiving a hit. Cover the rest by hand: inspect dataLayer in the console, use GTM Preview, search the Network tab for a fake test email, and review your container whenever it changes. A free read-only website audit is available, and the Free plan covers 1 site and 2 journeys with daily checks and no card.

Questions people ask

What is PII in the dataLayer?

It is personal data such as an email address, phone number, name or home address pushed into the dataLayer array. Any tag in Google Tag Manager can read these values, so they can be sent to several vendors at once.

Why is my email address showing up in GA4 or Meta?

Most often a form or checkout plugin pushes the email into the dataLayer, and a tag or variable maps it into an event parameter. Check GTM Preview and the Network tab to see which tag sends it, then remove the mapping and the push.

How do I check my dataLayer for personal data?

Open DevTools, type dataLayer in the Console and expand the entries after submitting a form with a fake email. Then use GTM Preview and the Data Layer tab on each event. Finally search the Network tab for the fake email.

Is it illegal to put emails in the dataLayer?

The dataLayer itself is not illegal, but passing personal data on to ad and analytics vendors without a lawful basis or consent can breach laws like GDPR. Google Analytics also prohibits sending PII. Ask your privacy lead or lawyer about your specific case.

How do I stop GTM sending PII to every tag?

Remove PII from the pushes at the source, delete variable mappings to PII in tags, and add a transformation or sanitising variable as a safety net. Send identifiers only to the vendor that needs them, using its documented feature and consent.

Can I send hashed emails instead of plain emails?

Some vendors ask for hashed customer data through features like enhanced conversions or Advanced Matching. Use those only in the relevant tag and with the right consent. Hashing is not a free pass to send it to every vendor.

Can FunnelGuard detect PII in my dataLayer?

Only partly. It checks that your tracking hits fire on real journeys, but it does not inspect every dataLayer push for personal data. Use the console, GTM Preview and the Network tab to cover the rest.

Does FunnelGuard catch this?

Partly

FunnelGuard checks part of this.

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.