How to filter out a subdomain in Google Analytics

How to filter out a subdomain in Google Analytics

Sometimes, you may want to filter out a subdomain ( or subdirectory ( from the rest of your Google Analytics data to get better insights into your audiences and their behavior.

In order to do so, you don’t need to do anything complicated with two analytics codes/accounts or anything, you can just set up a separate view in your existing Google Analytics account. As an added bonus, you can assign different access levels to different people for each view. This will allow the right people to be able to easily switch between the different views/domains.

Here’s how to set up a view filter for a subdomain or subdirectory:


filter out a subdomain in Google Analytics

  1. Make sure you have admin/editing access to the Google Analytics account
  2. In the view column, create a new view for your subdomain or subfolder
  3. Implement any existing filters that you want to apply to this view as well (e.g. filtering out IPs from your office)
  4. Choose a predefined filter
    • for subdomains: to include only traffic to the hostname that contain* 
    • for subdirectories: to include only traffic to the subdirectories that begin with*
  5. Add your domain or subdirectory
  6. Save

That’s it!

There are a couple of very important things to keep in mind when you filter out a subdomain:

  1. Filters are not retroactive. They will only apply to new data coming in. This is why it’s best to just create a new filter, and keep existing filters with all your data as is.
  2. Filters are destructive. You cannot reverse filters, so always make sure you have a view that contains all your clean data. If your goal is to filter out one subdomain from the rest of your data, we recommend to have at least three view filters:
    • A View that has all your data
    • A View that has ONLY data for your subdomain
    • A View that EXCLUDES your subdomain
  3. Decide what match type fits your needs:
    • ‘Begin with’ means nothing can come before the url you enter, but anything can come after
    • ‘End with’ means that anything can come before the url you enter, but nothing after
    • ‘Contains’ means that anything can come before and after the url you enter (e.g. and would both be included)
    • ‘Equals’ means that it will only take data for the exact url you enter.
    • If you need something more complicated (e.g. including or excluding multiple subdomains in the same View) you can create a custom filter and use regular expressions.
  4. Decide if you want to add a referral exclusion. If you don’t add a referral exclusion, your subdomain will show up as a referral to your own domain. If you do not want this, you’ll want to exclude this subdomain from your referral traffic in your property level > tracking info > referral exclusion list.

referral exclusion

For more information check out Google’s resources on the topic:

If you need more help with Google Analytics for your nonprofit, please get in touch. Our team would be more than happy to help.


Related Posts