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.
Example: one email typed in the search box can be stored in several places. Counts are illustrative and depend on your setup.
- Visitor searchesTypes an email into the search box
- URL built/search?q=jane@example.com
- GA4 eventsearch_term and page_location sent as typed
- 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
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.
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 @.
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.
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.
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.
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.
Preview and publish
Use Preview mode, search for test@example.com, and check that the outgoing request shows [redacted]. Then publish.
Find where search is tracked
Check whether a plugin such as Site Kit, or your GTM container, sends the search event. Fix it there when you can.
Use POST for search if your theme allows
Some themes and search plugins can submit the form with POST so the query stays out of the URL. This depends on the theme, and it also stops GA4 from reading the query.
Redact in GTM
If you use Google Tag Manager, follow the GTM tab.
Find your tracking source
Check whether tracking comes from the Google and YouTube app, a GTM snippet in theme.liquid, or a custom pixel under Settings, Customer events.
Redact in the tag
Shopify search uses /search?q=. In GTM, apply the redacting variable from the GTM tab. In a custom pixel, clean the URL before you send it.
Clean the URL in your gtag call
Pass a redacted page_location in your config call, as in the code below, and send search_term yourself after redacting it.
Turn off automatic search tracking if needed
In GA4 Admin, Data streams, Enhanced measurement, open the gear icon and switch off Site search if you plan to send your own event.
function() {
var url = {{Page URL}};
var email = /[A-Z0-9._%+-]+(@|%40)[A-Z0-9.-]+\.[A-Z]{2,}/gi;
return url.replace(email, '[redacted]');
}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)
});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.
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.
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.
Review your privacy notice
Make sure it explains how search data is used and kept.
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
- 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.
- 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.
Related issues
- TRK-355Email address in page URL query string sent to GA4Fix guide
- TRK-357Name or address in thank-you URL sent to pixelsFix guide
- TRK-358Form field values sent in GA4 click textFix guide
- TRK-360PII in dataLayer pushed to all vendorsFix guide
- TRK-361Hashed PII sent without consentFix guide
- TRK-356Phone number in event parametersFix guide