Talk to one of our Senior Strategists
Send us a message, and we’ll get back to you shortly.
Join us on Thursday, December 5th, at 12:00 PM (GMT +2) to gain a deeper understanding of GTM server-side tagging. Read more.
In this article, you’ll find a list of useful Google Analytics filters that can add value to your Google Analytics account and help you save a ton of time in the future.
P.S. You’ll also learn how to copy filters between Google Analytics accounts quickly and make bulk changes in filter definitions using a brilliant Google Sheet add-on. 👇
If you’d like to speed up the process of implementing Google Analytics filters, you can use this Filter Management for Google Analytics add-on that lets you:
1) Import all filters from your Google Analytics account to your Google Spreadsheet document
2) Modify filter definitions if needed
3) Add new filters or remove filters you don’t need
4) Export all the necessary filters to your desired Google Analytics account or update existing filters
If you would like to save your time and don’t want to copy view filters from this article to every single account one-by-one, you can easily export all of them to your Google Spreadsheet document and make changes there.
Note: It’s important to know that view filters only affect data going forward so the past data collected won’t be affected.
These kinds of filters exclude all hits that match the filter pattern, meaning that all matching lines are ignored. For example, if you create a filter that excludes mobile traffic, it also excludes all other information in that hit (such as hostname, page path, source, and browser information).
You could also use Regular Expressions in your exclude filter pattern if needed. You can read more about Exclude Filters in Google Analytics here.
Here are some examples of Google Analytics Exclude Filters.
Use case: You could identify sessions that are generated by your colleagues and exclude these sessions from you working views using an organization’s IP address range(s).
If your organization uses lots of different IP addresses for Internet access, you should get in touch with your organization’s IT support or network administrator to ask for external IP addresses (internal IP addresses usually start with 10, 172 or 192 so make sure you receive external IP addresses).
You could potentially exclude internal traffic using ISP Organization or ISP Domain as well instead of IP addresses. Here’s an example of the filter that excludes a specific IP address:
Note:
1) Make sure you insert your own and/or your organization’s IP address to the filter pattern, otherwise it won’t work.
2) If your co-workers visit your website or app from outside your organization’s networks, it’s much more difficult to exclude this traffic using an IP filter. It’s quite common that home-base IP addresses could be assigned dynamically, meaning that a single IP filter won’t be practical in most cases.
Important to know: If you’ve decided to anonymize IP data sent to Google Analytics servers (anonymizeIp = true), you need to keep in mind that it censors the last octet of the visitor’s IP (90.190.110.XXX) and sets it to 0 (90.190.110.0).
Alternative: For example, you could use Google Tag Manager and record user- or session-scope custom dimension and then exclude this custom dimension from your most important views.
Extra reading materials:
Use case: If you have exactly the same Google Analytics ID (code) installed in the test environment, your developers and testers are probably polluting your data. If you’d like to keep the messy, internal testing data separate from the clean and customer-oriented data, you could use this filter:
Note: Make sure you insert your own domain to the filter pattern, otherwise it won’t work.
Extra reading materials:
Use case: If you’d like to exclude referral spam, bots, and other sources of junk from your Google Analytics view, you could use this kind of filter:
Note: This filter pattern example above only excludes 3 different spam referrals. You can find potential spam referrals if you open your “Acquisition > All Traffic > Source / Medium” report in Google Analytics.
Important to know: Spammers modify traffic sources quite often, meaning that you might need to keep an eye on your data and update this filter on a regular basis if needed. You can find a list of different potential spam sources you might want to exclude here.
Extra reading materials:
This type of filter includes all hits that match the filter pattern, meaning that all non-matching hits are ignored in your Google Analytics reports.
You could also use Regular Expressions in your include filter pattern if needed. You can read more about Include Filters in Google Analytics here.” and link to here.
Here you can find examples of Google Analytics include filters.
Use case: This is one of the best filters to help you remove spam from GA. Each time a page is viewed on your website, one of the pieces of information that is passed back to Google Analytics is the domain (hostname) of your site on which the page was viewed. If you’d only like to include hits generated by people visiting your domain, you should implement this Hostname filter. This helps you exclude a bunch of ghost referral spam that never actually hits your site.
Note: This filter pattern described above will also include all the different subdomains (landing.yourdomain.com, live.yourdomain.com etc). If you’d like to include only specific subdomains, you could use this kind of regex in the filter pattern field: ^(landing.|www.|app.|live.)yourdomain.com$
Important to know:
Extra reading materials:
Use case: For example, if you create a separate view for Canada and USA, you could see how many sessions start in each without applying an advanced segment to your Master View every time.
Note: You can include one or more countries using a regex in the filter pattern. You could also track data from smaller geographical regions, such as specific cities and states. If you don’t have sampling issues, it’s better to use Advanced Segments to get the data you need for specific countries or regions.
Important to know:
1) Include Filters do not work cumulatively. You should never apply two or more Include Filters to one view with the same filter field values. Use regular expressions instead.
2) You can only create 25 views in Google Analytics.
3) This filter makes a lot of sense if you’re constantly running into sampling issues in Google Analytics but you don’t want to upgrade to GA360. If you have sampling issues and you apply any segments to your Master View, it’ll get sampled, but the standard reports will hold the unsampled information. If you’d like to dig a little deeper in your reports than your standard reports allow you to do in the Master View, you could use this kind of filter:
Extra reading materials:
Use case: The only benefit to separate views for each device category (mobile, tablet, desktop) at this point is to prevent sampling. If you don’t have any sampling issues, you could simply use advanced segments and you don’t need separate views for each device category. This kind of filter is like applying a mobile-only segment to all of your reports (but without sampling).
Note: Unfortunately, Google Analytics doesn’t allow you to include 2 different device categories at the same time. If you’d like to include both “desktop” and “tablet” traffic, you should create a filter that excludes “mobile” traffic.
Important to know: Include Filters do not work cumulatively. You should never apply two or more Include Filters to one view with the same filter field values. It means that you should never apply 2 separate filters (for example “Include Desktop Only” and “Include Tablet Only”) to the same view. It won’t work.
Extra reading materials:
Use case: If you’ve configured a Custom Dimension in Google Analytics that includes Order Coupon values, you could simply use them to filter your sessions. Let’s say that you have 5 partners that help you generate more revenue, and they all have their own coupon code that they’re sharing with their followers on Instagram, Facebook, and Youtube. Now, if you’d like to give them access to the specific revenue data, you could simply create a filter in Google Analytics that includes only sessions with a specific coupon code.
Note: In order to create this kind of filter, you need to pick up coupon code values from your website and send them to GA using a session- or user-level custom dimension. Google Analytics won’t do it automatically, meaning that it requires customization.
Extra reading materials:
This filter converts the contents of the filter field into all lowercase characters. Keep in mind that it only affects letters and does not affect special characters or numbers.
Use case: Google Analytics treats case variations as separate dimension values. We could apply a lowercase filter for Campaign Names to avoid having different case variations in your reports. For example, instead of seeing two different campaign name values: “Summer Sale 2018” and “Summer sale 2018” in your acquisition reports, you could consolidate them and see only the lowercase version.
Use case: You could apply a lowercase filter for Campaign Sources to avoid having different case variations in your reports. For example, instead of having 2 different campaign source values: “Facebook.com” and “facebook.com” in your acquisition reports, you could consolidate them and see only the lowercase version.
Use case: You could apply a lowercase filter for Campaign Mediums to avoid having different case variations in your reports. For example, instead of having 2 different campaign medium values: “Email” and “email” in your acquisition reports, you could consolidate them and see only the lowercase version.
Use case: You could apply a lowercase filter for Campaign Terms to avoid having different case variations in your reports. For example, instead of having 2 different campaign term values: “Version 1” and “version 1” in your acquisition reports, you could consolidate them and see only the lowercase version.
Use case: You could apply a lowercase filter for Campaign Content to avoid having different case variations in your GA reports. For example, instead of having 2 different campaign content values: “top link” and “Top Link” in your acquisition reports, you could consolidate them and see only the lowercase version.
Use case: You could apply a lowercase filter for internal site search terms to avoid having different case variations in your Site Search reports. For example, instead of having 2 different site search term values: “blue t-shirt” and “blue T-shirt” in your Behavior -> Site Search reports, you could consolidate them and see only the lowercase version.
Use case: You could use a lowercase filter to reconcile case variations in the page paths. For example, instead of having 2 different page path variations: “/Google-Analytics-Consultation/” and “/google-analytics-consultation/” in the Behavior > Site Content > All Pages report, you could consolidate them and see only the lowercase version.
Note: Request URI is the same as the dimension simply referred to as Page in Google Analytics’ reports.
Important to know: Keep in mind that case variations can be indexed separately by search engines, so if you lowercase Request URI in Google Analytics, you may hide a potential SEO issue that you may have.
This filter type helps you search for a pattern within a field and replace the found pattern. You could also use Regular Expressions in your search and replace filter “Search String” field if needed.
You can read more about Search and Replace Filters in Google Analytics here.
Use case: If you’re seeing unconventional Facebook sources (lm.facebook.com, l.facebook.com, m.facebook.com, web.facebook.com) in your Google Analytics reports and it makes your data analysis process much more difficult, you could simply combine them in one using this filter:
Note: Read this article if you’d like to know what’s hidden behind these mysterious Facebook referrals, you could read this article.
Important to know:
1) If you or your colleagues use Google Analytics UTM parameters and “facebook” or “Facebook” as a source name (for example: utm_source=facebook), this Search and Replace filter will automatically replace it with “facebook.com” in your reports and make it easier for you to analyze data.
2) Always test your Search String using a Table Filter feature in your Google Analytics reports before you start using it in the filter. Also, it’s highly recommended to test it in the test view before applying it your Master View.
Extra reading materials:
Use case: If you’re seeing different Instagram sources (lm.instagram.com, l.instagram.com, m.instagram.com, etc) in your Google Analytics reports and you’d like to combine all them in one, you could use this filter:
Important to know:
1) If you or your colleagues’ use Google Analytics UTM parameters and “instagram” or “Instagram” as a source name (for example: utm_source=instagram), this Search and Replace filter will automatically replace it with “instagram.com” in your reports and make it easier for you to analyze data.
2) Always test your Search String using a Table Filter feature in your Google Analytics reports before you start using it in the filter. Also, it’s highly recommended to test it in the test view before applying it to your Master View.
Use case: If you’re seeing different Pinterest sources (fr.pinterest.com, br.pinterest.com, pinterest.se, pinterest.co.uk) in your Google Analytics reports and you’d like to combine all them in one, you could use this filter:
Note: If you’d like to combine only pinterest.com sources in one and do not want to include other Pinterest domains (pinterest.se, pinterest.co.uk etc), use this Search String “(^|.*.)pinterest.com$” instead of this “(^|.*.)pinterest.(.*)”.
Important to know:
1) If you use Google Analytics UTM parameters and “pinterest” or “Pinterest” as a source name (for example: utm_source=pinterest), this Search and Replace filter will automatically replace it with “pinterest.com” in your reports and make it easier for you to analyze data.
2) Always test your Search String using a Table Filter feature in your Google Analytics reports before you start using it in the filter. Also, it’s highly recommended to test it in the test view before applying it your Master View.
Use case: If you’re seeing different Twitter sources (t.co, twitter, twitter.com etc) in your Google Analytics reports and you’d like to combine all them in one, you could use this filter:
Note: t.co is a link shortener similar to bitly used by Twitter.
Important to know:
1) If you use Google Analytics UTM parameters and “twitter” or “Twitter” as a source name (for example: utm_source=twitter), this Search and Replace filter will automatically replace it with “twitter.com” in your reports and make it easier for you to analyze data.
2) Always test your Search String using a Table Filter feature in your Google Analytics reports before you start using it in the filter. Also, it’s highly recommended to test it in the test view before applying it to your Master View.
Use case: If you’re seeing different LinkedIn sources (linkedin, linkedin.com, lnkd.in etc) in your Google Analytics reports and you’d like to combine all them in one, you could use this filter:
Note: lnkd.in is a link shortener similar to bitly used by LinkedIn.
Important to know:
1) If you use Google Analytics UTM parameters and “linkedin” or “LinkedIn” as a source name (for example: utm_source=linkedin), this Search and Replace filter will automatically replace it with “linkedin.com” in your reports and make it easier for you to analyze data.
2) Always test your Search String using a Table Filter feature in your Google Analytics reports before you start using it in the filter. Also, it’s highly recommended to test it in the test view before applying it to your Master View.
Use case: If you analyze your Behavior > Site Content > All Pages report, you may notice that some of the page paths are split across different rows, making it harder for you to analyze data. This is usually caused by different query parameter values. Query parameters consist of name-value pairs joined by equal sign, with multiple parameters separated by ampersands. If you’d like to remove all query parameters from URLs, you can use this custom filter:
Note:
1) Request URI is the same as the dimension simply referred to as Page in Google Analytics’ reports.
2) You can always use the built-in Exclude URL Query Parameters option at the View level for the most basic query parameter issues. When accounts have 100+ views across multiple properties, it can be tedious to update this setting. That’s why it’s better to use a custom filter. In addition, it’s not recommended to use a filter to exclude PII data. Hits including PII data should be blocked at the collection level (i.e. using GTM).
Important to know:
1) You might not want to remove query parameters that add value to your analysis. If you’d like to exclude only a specific query parameter, read this article.
2) If you implement this filter, make sure you create a new annotation in GA and inform your colleagues about the change as well.
Extra reading materials:
Use case: Sometimes long URLs can make your reports hard to read. You can simplify them by removing directories. For example, here’s how you could turn “/directory/category/t-shirts/” into “/category/t-shirts/”:
Note:
1) Request URI is the same as the dimension simply referred to as Page in Google Analytics’ reports.
2) If you use this filter to rewrite the URLs that appear in your reports (e.g., in the All Pages report), the links in your reports based on the rewritten URLs may not work.
Important to know: If you implement this filter, make sure you create a new annotation in GA and inform your colleagues about the change as well.
Extra reading materials:
Use case: Google Analytics usually treats www.yourdomain.com and yourdomain.com as separate hostnames even though they serve the same content. If you’re receiving hits from both hostnames (domains), your traffic to this content will be split across two different URLs in your Google Analytics reports. You can prevent this by consolidating both hostnames into “yourdomain.com”:
Note: You can find all hostnames, if you open: Audience > Technology > Network > Hostname (Primary Dimension) report in your Google Analytics account.
Extra reading materials:
Use case: If your page paths contains numeric codes (such as content category IDs, product IDs, or similar in your Google Analytics reports), you can use multiple search and replace filters and change mysterious numbers to intuitive names.
Your page path in Google Analytics reports might look like this:
/en/category/jeans/?sexId=1&sort=created&sortOrder=desc&pageSize=50
But if you apply search and replace filter, you could change it to this:
/en/category/jeans/?sexId=woman&sort=created&sortOrder=desc&pageSize=50
Here’s how:
Note: If there’s a chance that the page path could end up with “sexId=1” (there’s no ampersand – &), you can use another filter that takes this into account:
Note:
1) Request URI is the same as the dimension simply referred to as Page in Google Analytics’ reports.
2) If you use this filter to rewrite the URLs that appear in your reports (e.g., in the All Pages report), the links in your reports based on the rewritten URLs may not work.
Important to know: If you implement this filter, make sure you create a new annotation in GA and inform your colleagues about the change as well.
Extra reading materials:
Use case: When visitors can access a page with or without using “.html” at the end of the URL, Google Analytics will record a separate pageview for each case. If you see separate rows in your Behavior > Site Content > All Pages report for the same page paths (for example: /services/ and /services.html), you may want to create this filter:
Note:
1) Request URI is the same as the dimension simply referred to as Page in Google Analytics’ reports.
2) You can find all Page Paths, if you open: Behavior > Site Content > All Pages report in your Google Analytics account. If you’d like to figure out page paths that contain “.html”, type “.html” in the Table Filter box.
Important to know: Double-check the Default URL field in your Google Analytics view settings before you apply this filter.
Extra reading materials:
Advanced filter allows you to build a field from one or two other fields. The filtering engine applies the expressions in the two extract fields (A and B) to the specified fields and then constructs a third field using the constructor expression.
You can read more about Advanced Filters in Google Analytics here.
Use case: By default, the data in your Google Analytics reports includes only the page path and not the domain name. For example, If you’re using subdomains or cross-domain tracking, it would be useful to see full page URLs in your reports, not only page paths. Here’s how you can prepend Hostname to Request URI:
Note:
1) Request URI is the same as the dimension simply referred to as Page in Google Analytics’ reports.
2) If you use this filter to rewrite the URLs that appear in your reports (e.g., in the All Pages report), the links in your reports based on the rewritten URLs may not work.
Important to know: This URL rewrite filter described above can affect your Analytics’ ability to match your goals properly. If you use “Destination Type” goal in Google Analytics along with conditions like “Equals to” or “Begins with”, you may need to change your goal settings.
For example, if you used “/thank-you/” request URI in your destination type goal before with “Equals to” or “Begins with” conditions, you now need to replace it with “yourdomain.com/thank-you/” after applying this filter. If you don’t do that, you destination type goal will stop working properly.
Extra reading materials:
Use case: It’s common to see traffic from websites and apps that Google Analytics recognizes as Social Networks are still recorded with “referral” as a medium. If you wish to see “social” instead of “referral” as a medium in Google Analytics for organic social network traffic, you can configure this filter:
Note:
1) You don’t need to specify the full source names in the “Extract A” field.
2) Keep in mind that there’s a 255-character limit in the filter field. You could use Regular Expressions in the “Extract A” field.
Important to know: In most cases, Google Analytics classifies social network traffic correctly as Social in the Default Channel Grouping, even if the “medium” is recorded as “referral”. This filter just simplifies your analysis if you prefer to identify social traffic wherever “medium” is displayed.
Bonus: Before you copy-paste the “Extract A” field described above, open this Custom Report in your Google Analytics account and analyze different sources and mediums to figure out which mediums you should rewrite from “referral” to “social” using this advanced filter.
Extra reading materials:
Use case: Let’s say that your site is yourdomain.com and all page titles look like this: “Your Domain | Page Title.” If you’d like to see only text after the pipe (|) symbol as the Page Title in your Google Analytics reports, you can use this filter:
Note: You can simply replace pipe (|) with the dash (-) or colon (:) in the “Extract A” field if needed.
Extra reading materials:
Use case: If you analyze your Behavior > Site Content > All Pages report, you may notice some page paths are split across different rows because of different query parameters. If you’d like to remove all query parameters from page paths, you could simply use Search and Replace filter that is described above or you can use this Advanced filter:
Note:
1) Request URI is the same as the dimension simply referred to as Page in Google Analytics’ reports.
2) You can always use the built-in Remove Query Parameters option at the View level for the most basic query parameter issues. When accounts have 100+ views across multiple properties, it can be tedious to update. That’s why it’s better to use a filter.
In addition, it’s not recommended to use a filter to exclude PII data. Hits including PII data should be blocked at the collection level (i.e. using GTM).
Important to know:
1) You might not want to remove query parameters that add value to your analysis. If you’d like to exclude only a specific query parameter, read this article.
2) If you implement this filter, make sure you create a new annotation in GA and inform your colleagues about the change as well.
Extra reading materials:
Use case: When your site visitors can access your page with or without using a trailing slash (for example: “/services/” and “/services”), this could be a problem because GA would record a separate pageview for each case. If you’d like to avoid the same page split across different rows in our Google Analytics reports, you may want to append a slash to page paths using this filter:
Note:
1) Request URI is the same as the dimension simply referred to as Page in Google Analytics’ reports.
2) You probably don’t want to include a question mark (?), equal sign (=), ampersand (&), dot (.) or hash mark (#) in this regular expression (Extract A field) because otherwise you could end up seeing a slash (/) at the end of these page paths in your reports as well:
a) /services/car-repair.php
b) /services/car-repair/?category=audi&product=a3
c) /services/?search=audi%20quattro
You may need to adjust a regular expression in the Extract A field a little if you’d like to append a slash to page paths that include characters other than:
a) alphabet (a-z)
b) numbers (0-9)
c) underscore (_)
d) hyphen (-)
Important to know:
1) Filter order matters in Google Analytics. If you use this advanced filter, make sure you test it in the test view first and move it to the last filter in the view so that it won’t interfere with other filters.
2) If you already use a “View Full Page URL instead of Page Path” filter described above and prepend a Hostname to Request URI, you may need to modify this advanced filter to work as expected.
Extra reading materials:
Use case: When your site visitors can access your page with or without using a trailing slash (for example: “/contact-us/” and “/contact-us”), this could be a problem because GA would record a separate pageview for each case. If you’d like to avoid the same page split across different rows in our Google Analytics reports, you may want to remove a slash from page paths using this filter:
Note: Request URI is the same as the dimension simply referred to as Page in Google Analytics’ reports.
Important to know: If you implement this filter, make sure you create a new annotation in GA and inform your colleagues about the change as well.
Extra reading materials:
Use case: If your search results URLs look like “/search/umbrellas”, where “umbrellas” in the search term, you cannot use the regular Site Search tracking configuration that you can find in the view settings. Instead of that, you can use this filter to pull values out of URLs into the appropriate field:
Note:
1) Request URI is the same as the dimension simply referred to as Page in Google Analytics’ reports.
2) You can also capture a category with this method if it’s applicable to your site search.
Important to know:
1) Filter order matters in Google Analytics. If you apply this extract filter and also Search Term lowercase filter described above to the same view, make sure to position the lowercase filter after the extract filter so it can lowercase all search terms as output from the extract filter.
2) If you implement this filter, make sure you create a new annotation in GA and inform your colleagues about the change as well.
Extra reading materials:
Use case: Let’s say that you have lots of different similar page paths in your Google Analytics reports:
1) /checkout/cart/configure/id/545791/
2) /checkout/cart/configure/id/12334
3) /checkout/cart/configure/id/545791/?itm_placement=123d
4) /checkout/cart/configure/id/545791/logged-in
5) /checkout/cart/configure/id/545791/logged-out/success
… and you’d like to remove two subdirectories (/configure/id/) and dynamic IDs from these page paths and replace them with {IDs}:
1) /checkout/cart/{IDs}
2) /checkout/cart/{IDs}
3) /checkout/cart/{IDs}/?itm_placement=123d
4) /checkout/cart/{IDs}/logged-in
5) /checkout/cart/{IDs}/logged-out/success
If you see lots of these fragmented URLs in your Google Analytics reports and would like to clean them to improve readability, you can use this advanced filter:
Note: This regular expression is true when the Request URI begins ^ with (/checkout/cart/) followed by (/configure/id) and 1 or more random digits [0-9]. Finally, we capture the remainder of the URI using (.*). Groups () are used to extract the values and will be used in a later step. $A1 extracts the 1st group (/checkout/cart/) from Field A. $A5 would extract the 5th group (.*) from Field A, if it were to exist. {IDs} is a static string that is a placeholder for subdirectories and dynamic values.
Tip: Use this tool to test your regular expressions before you use them in your filter settings. In addition, apply this filter to the “Test View” first, not “Master View” to make sure it works as expected.
Extra reading materials:
This list of Google Analytics filters is certainly not exhaustive, and I’m sure you have other suggestions to what could be considered “useful.”
Do you have some go-to Google Analytics custom filters you’d recommend?
Let us know in the comments & let’s make this list even more useful to readers like you.