Skip to content
FunnelGuard

Fix guide by FunnelsGuard

PII in site search tracking: how to find and fix it

TRK-365Medium impactPartlyBy FunnelGuardPublished Updated
On this page

What this issue is

Site search usually puts what the visitor typed into the URL, for example /search?q=jane.doe@example.com. GA4 enhanced measurement reads that query parameter and sends it as a view_search_results event with a search_term value. The full URL is also sent as page_location, and often as page_referrer on the next page.

Why it costs you leads or sales

The cost is mostly risk. Google's Analytics terms forbid sending personally identifiable information to Google Analytics. Data protection law such as GDPR also treats an email address in a log as personal data that needs a legal basis, a retention limit and a way to delete it. Collecting it by accident is a compliance problem, and it can force you to delete data or reports.

Where one typed email can end upExample numbers
Where one typed email can end up (example)Server logs: 1 copies; GA4 page_location: 1 copies; GA4 search_term: 1 copies; Ad pixel page URL: 2 copies0121112Server logsGA4 page_locationGA4 search_termAd pixel page URLcopies

Example: one email typed in the search box can be stored in several places. Counts are illustrative and depend on your setup.

How a search query leaks
  1. Visitor searchesTypes an email into the search box
  2. URL built/search?q=jane@example.com
  3. GA4 eventsearch_term and page_location sent as typed
  4. Ad pixelsPage URL copied to other vendors

The leak happens at the URL step, so every later copy carries the personal data.

How to check if your site has it

Check for PII in search tracking
  1. Open the GA4 search terms report

    In GA4 go to Reports, then Engagement, then Events, open view_search_results, and look at the search_term values. If search_term is not a registered custom dimension, create it first under Admin, Custom definitions. Look for @ signs, digits that look like phone numbers and names.

  2. Search page paths for the @ sign

    In Reports, Engagement, Pages and screens, switch the dimension to Page path and query string. Filter for a contains match on @ or on %40, the encoded form of @.

  3. Test it yourself

    Search for test@example.com on your site. Open GA4 DebugView or the browser Network tab, filter for collect, and check whether dl (page location) or the search_term parameter holds the address.

  4. Check other tags

    In the same Network tab, look at requests to Meta, Google Ads and other vendors. Their URL or dl parameters may carry the same query.

How to fix it

There are three parts: stop sending the raw query, remove what is stored, and reduce how often people type personal data. The best place to redact depends on your setup.

Redact the search query before it is sent
  1. Create a redacting variable

    Add a Custom JavaScript variable that returns the page URL with email-like values replaced by [redacted]. Use the code below.

  2. Override page_location

    In your GA4 Configuration or Google tag, add the field page_location under Fields to set, using the new variable. If you use a GA4 event tag for view_search_results, set search_term to a redacted version too.

  3. Preview and publish

    Use Preview mode, search for test@example.com, and check that the outgoing request shows [redacted]. Then publish.

GTM Custom JavaScript variable: redacted page URLjavascript
function() {
  var url = {{Page URL}};
  var email = /[A-Z0-9._%+-]+(@|%40)[A-Z0-9.-]+\.[A-Z]{2,}/gi;
  return url.replace(email, '[redacted]');
}
gtag.js: send a redacted page_locationjavascript
var redact = function (s) {
  return s.replace(/[A-Z0-9._%+-]+(@|%40)[A-Z0-9.-]+\.[A-Z]{2,}/gi, '[redacted]');
};
gtag('config', 'G-XXXXXXX', {
  page_location: redact(location.href)
});
Clean up and reduce the problem
  1. Delete stored data

    In GA4 Admin, Data collection and modification, Data deletion requests, create a request for the affected parameters. Deletion also applies to data already collected, and it can take time to process.

  2. Clean other vendors

    Check Google Ads, Meta and other platforms that received the URL, and use their own deletion or data-removal tools where they exist.

  3. Add a hint to the search box

    Use placeholder text such as Search products or articles. Do not enter personal details. This lowers how often visitors type their own data.

  4. Review your privacy notice

    Make sure it explains how search data is used and kept.

Search tracking before and after

Before

  • page_location shows /search?q=jane@example.com
  • search_term holds the typed email
  • Ad pixels receive the same URL

After

  • page_location shows /search?q=[redacted]
  • search_term is redacted or removed
  • Ad pixels receive the cleaned URL

How to confirm it's fixed

Confirmation checks
  • Search for test@example.com and see [redacted] in GTM Preview or DebugView
  • The Network tab shows no @ or %40 in requests to GA4
  • Requests to Meta, Google Ads and other vendors show the cleaned URL
  • The Page path and query string report shows no new @ values after the change
  • The data deletion request for old values is completed

How to prevent it happening again

New tags are the usual cause of a return. A new pixel or plugin may read the raw URL and bypass your redaction. Route every tag through one cleaned URL variable where you can.

Prevention habits
  • Review the GA4 search term report every month for @ signs and digit strings
  • Re-test with a dummy email after every tag, theme or plugin change
  • Keep one shared redaction variable in GTM and reuse it
  • Note the redaction in your tracking documentation so a new developer does not remove it
  • Re-run the test after changing the search plugin or search URL format

How FunnelGuard handles this

FunnelGuard detects this only partly. Its robot visitor runs your journeys on a schedule and checks the tracking hits sent to GA4, Google Ads, Meta and other platforms, so it can see what those requests contain on the steps it visits. It does not know what real visitors type into your search box, and it will not find personal data that people typed in the past.

Questions people ask

Why is my GA4 search term report showing email addresses?

Visitors typed them into your search box. GA4 enhanced measurement reads the search query from the URL and stores it as search_term. Redact the value before it is sent and delete what is stored.

Is it against Google Analytics rules to collect emails in search terms?

Yes. Google's terms forbid sending personally identifiable information to Google Analytics, even when it was collected by accident. You should stop sending it and request deletion of the stored data.

How do I remove personal data from GA4 site search?

Redact the value before it is sent, for example with a Google Tag Manager variable that replaces email patterns in page_location and search_term. Then create a data deletion request in GA4 Admin, Data collection and modification, for the data already stored.

How do I find PII in my site search reports?

Open the view_search_results event and read the search_term values, then filter Page path and query string for @ or %40. Also search for a dummy email and check the request in DebugView.

Can I stop GA4 tracking site search?

Yes. In Admin, Data streams, open your web stream, Enhanced measurement, the gear icon, and switch off Site search. You can then send your own search event with a cleaned value.

Does the leak reach Google Ads and Meta too?

It can. Those tags often send the page URL, which contains the query. Check their requests in the Network tab and apply the same cleaned URL to every tag.

Can FunnelGuard find personal data in my search terms?

Only partly. It checks the tracking hits sent on the journeys it runs, but it does not see what real visitors typed or what was stored in the past. Check your GA4 reports by hand each month.

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.