Google Analytics: Remove Email Addresses.

How to define a filter for redacting email addresses from Google Analytics.

Adam Phillabaum
2 min readMar 18, 2014

Did you know that it’s against the Google Analytics Terms of Service to capture email addresses in their system? It is, and so is any other personally identifiable information (PII).

You will not (and will not allow any third party to) use the Service to track, collect or upload any data that personally identifies an individual (such as a name, email address or billing information), …

If you run a site of any sufficient size, you know that this is next to impossible. People put crazy stuff in form fields, regardless of what you intend for them to put there.

Before we start, I have to point out one downside: all of your defense against PII collection is done at the “profile” level. It might make sense for Google Analytics to move these to the “property” level, because it make sense to have some filters property-wide. What this means for you: you’ll have to apply these filters to any profile you create. That’s OK though, because I have a feeling most people only have one or two profiles anyways.

View Settings

Your first line of defense: View Settings

Your first line of defense is to exclude any parameter you KNOW will have an email address on it here. It’s just a comma separated list. THIS IS CASE SENSITIVE, so make sure you get that right. Maybe the topic for another post, but you could also lowercase all the data coming into your profile.

The Advanced Filter

An advanced filter to remove email addresses

Here comes the magic. Well, here comes the RegEx for email addresses at least. Here is the filter you want:

  • Field A -> Extract A
    Request URI
    ^(.*)=([A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4})(.*)$
  • Field B -> Extract B can be left empty
  • Output To -> Constructor
    Request URI
    $A1=\[email redacted\]$A3
  • The radio buttons should be selected as shown in the screenshot.

I hope this helps you. I tried a couple of other solutions (mostly with the Search and Replace filter type), but didn’t have any success. But, this works.

If you have any feedback about (a) how this might be breaking something, or (b) might be improved. Please let me know.

--

--

Adam Phillabaum

Production Engineering at @facebook. I like to hack stuff together. Skier. Chinese food addict. Parentally experimenting with @mckb0mb.