The problem with personal data
Personal data (PII) sometimes slips unintentionally into the URLs collected: an email address in a confirmation page, a file number in a claim form, a licence plate in a customer area. Each of these URLs goes to Google Analytics, is stored there and stays accessible to anyone who has access to the reports.
This is personal data under the GDPR, sometimes sensitive contractual data. Its presence in analytics tools is not covered by your processing register and goes against Google's terms of use. The Data Protection Authority can therefore impose penalties. Even an encrypted or hashed identifier remains personal data if it can be used to identify the person.
The usual reaction is to clean the page URL. That is necessary but not enough.
Where PII hides in Google Analytics
In Google Analytics, the same URL is collected in 4 distinct variables:
- The page URL (
page_location). The most obvious one, the one everybody checks. - The click URL (
link_url,form_destination). When a visitor clicks a link or submits a form, the destination is collected with the event. A "View my file" link that contains the file number is therefore sent on every click, even if the destination page is cleaned. - The landing page, calculated from the first page of the session. If the visitor arrives from an email with their address as a parameter, the landing page keeps it for the whole session.
- The previous page (
page_referrer). Each page view carries the URL of the page before, so a confirmation page with an email in the URL contaminates the next page, under another dimension.
The last 2 cases are the most misleading: you clean page_location, the pages report looks clean, but the landing page and the previous page are fed separately and the data persists there.
How to spot PII in your URLs
2 approaches exist, depending on the size of the site.
By URL
On a small site, list the known URLs that carry parameters and check each dimension in a Google Analytics exploration: page, previous page, landing page, click URL. An exploration in table format is enough for a first pass.
By parameter extraction
On a site with several hundred pages, look for parameters rather than URLs. A regular expression extracts all the URL parameters of each dimension, then you just sort them by name and frequency. Telling names (email, file, plate, customer, iban, phone) stand out immediately, whereas neutral names (id, ref, q) need a check of the value.
In Sheets, paste the exported URLs in column A (from A2), then type the formula below in B2 and drag it down. Each parameter (name=value) appears in its own cell, to the right of the URL.
=IFERROR(SPLIT(REGEXEXTRACT(A2,"\?([^#]*)"),"&"),"")
With a Sheets set to French, replace the commas in the formula with semicolons. Repeat for each of the 4 dimensions.
The fix
In Google Analytics
GA4 offers native data redaction at stream level: masking of email addresses and chosen URL parameters, applied before sending, on the page URL, the previous page, the click URL and the form destination. This is the setting to turn on first, because it needs no resource on the site and covers the 4 variables at once.
Upstream, in Google Tag Manager
A GTM variable can also rewrite the URL before the tag fires: removal of the listed parameters, replacement of values with a marker. This approach protects all the tags in the container (Ads, Meta, third-party tools), not just GA4. However, the cleaning runs in the visitor's browser, on every page view and every click, which adds JavaScript to the site.
The practical rule: native cleaning in GA4 first, GTM as a complement only if other tags are exposed.
And how to delete the sensitive data already collected?
Cleaning only applies to the future: the data already collected stays in Google Analytics. To delete it, the tool offers data deletion requests by parameter and by date range.
The check on every new flow
The problem comes back with every release: a new form, a new funnel, a transactional email with one more parameter. The check is therefore part of the deployment QA, just like checking the events:
- Walk through the new flow in debug mode and read the 4 variables on every hit.
- Replay the extraction expression on the first week's data.
- Add the newly identified parameters to the native redaction list, before the history fills up.
Tools
- Google Analytics 4: explorations, stream data redaction, data deletion requests.
- Google Tag Manager: URL rewriting variable, preview mode for QA.
- Sheets: parameter extraction by regular expression on the 4 dimensions.
Cleaning personal data is part of the tracking expertise, together with consent mode and the container audit.