30+ Custom View Filters For Google Analytics

Google AnalyticsMost Popular

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. 👇

Table of contents

How to copy all Google Analytics filters from one account to another and make bulk changes in Google Sheets

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.

Important things to keep in mind before creating Google Analytics filters

    • Google Analytics filters enable you to make permanent changes to your data.  If you don’t want to permanently alter your data, use segments instead.View Filters allow you to permanently:
      • Modify your data (for example, convert page URLs into more human-readable text strings)
      • Include only specific data (for example, include only mobile traffic)
      • Exclude specific data (for example, exclude your own employees’ interactions on the site)

      Note: It’s important to know that view filters only affect data going forward so the past data collected won’t be affected.

    • Make sure you have at least 3 different views in your Google Analytics property before creating filters:

      1)
      Master View: It’s the most important and accurate view that you can use on a daily basis to analyze data.

      2) Raw Data View: It’s the backup view that shouldn’t include any filters. In case something goes wrong with the Master View, you will have at least one unfiltered view that contains your full data set.

      3) Test View – It’s a view that you could use for testing purposes to ensure that filters work properly. If you don’t test any new view filters or settings, Test View should have exactly the same configuration that you have in the Master View.
    • Always test new filters in the Test View first before applying them to the Master View. If everything works as expected, you could easily apply a new filter to the Master View.
    • Filters require up to 24 hours before they are applied to your data.
    • You need to have “Edit” permission at the account level to create, edit, and apply new filters. If you have Edit permission at the view level, you can only apply existing filters to or remove them from that view.
    • Filter order matters. Make sure you arrange the filters in the correct order.

    • Use the account level filters to accelerate your workflow.

    • Filters that rewrite a dimension value are not applied when a session appears in the Real-Time report. All “include” and “exclude” filters apply to Real-Time reports.

    • Keep the naming conventions of your view filters organized and easy to understand.  Your filter name should inform you about what the filter actually does.
    • Include Filters do not work cumulatively. Never apply two or more Include Filters to one view with the same filter field values. “Include” means “exclude everything else” in the Include Filters.

A list of Google Analytics custom filters

Exclude filters – exclude sessions that match a rule

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.

1. Exclude Internal Traffic by IP address

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:

  • Filter Name: Exclude – IP address – Internal traffic
  • Filter Type: Custom > Exclude
  • Filter Field: IP Address
  • Filter Pattern: 90.190.110.122

Exclude Internal Traffic by 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:

2. Exclude DEV, TEST, STAGING & PROD Hostnames (environments)

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:

  • Filter Name: Exclude – Hostname – DEV, TEST, STAGING, PROD
  • Filter Type: Custom > Exclude
  • Filter Field: Hostname
  • Filter Pattern: ^(dev.|test.|staging.|prod.)yourdomain.com$

Exclude DEV, TEST, STAGING & PROD Hostnames (environments)

Note: Make sure you insert your own domain to the filter pattern, otherwise it won’t work.

Extra reading materials:

3. Exclude Crawler and Referral Spam

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:

  • Filter Name: Exclude – Campaign Source – #1 Spam
  • Filter Type: Custom > Exclude
  • Filter Field: Campaign Source
  • Filter Pattern: 1-99seo.com|1-free-share-buttons.com|a.pr-cy.ru

Exclude Crawler and Referral Spam

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:

Bonus: If you would like to save time, you can easily download all the “Exclude Filters” described in this article to your Google Spreadsheet document, make necessary changes there, and import what you need to your desired Google Analytics account using the Filter Management for Google Analytics add-on.

Include filters – include sessions that match a rule

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.

1. Include youdomain.com Hostname (domain) only

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.

  • Filter Name: Include – Hostname – yourdomain.com
  • Filter Type: Custom > Include
  • Filter Field: Hostname
  • Filter Pattern: yourdomain.com$|youtube.com$|yourdomain.googleweblight.com$|translate.googleusercontent.com$

Include youdomain.com Hostname (domain) only

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:

  1. Make sure you include all the valid hostnames before you start implementing this filter.  You could find all your hostnames if you choose a long enough date range and open the Audience > Technology > Network > Hostname report in Google Analytics.  If you’d like to know the meaning of different hostnames, read an amazing article written by Carlos.
  2. Don’t forget to use your own domain, not the example (yourdomain.com) mentioned in this filter pattern.

Extra reading materials:

2. Include X, Y & Z Countries only

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.

  • Filter Name: Include – Country – Canada and United States
  • Filter Type: Custom > Include
  • Filter Field: Country
  • Filter Pattern: Canada|United States

Include X, Y & Z Countries only

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:

3. Include only Mobile, Desktop or Tablet traffic

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).

  • Filter Name: Include – Device Category – Mobile
  • Filter Type: Custom > Include
  • Filter Field: Device category
  • Filter Pattern: Mobile

Include only Mobile, Desktop or Tablet traffic

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:

4. Include only XYZ Coupon Codes

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.

  • Filter Name: Include – Custom Dimension – Coupon Code – summer-sale-1
  • Filter Type: Custom > Include
  • Filter Field: Coupon Code
  • Filter Pattern: summer-sale-1

Include only XYZ Coupon Codes

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:

Bonus: If you would like to save your time, you can easily download all the “Include Filters” described in this article to your Google Spreadsheet document, make necessary changes there, and import what you need to your desired Google Analytics account using the Filter Management for Google Analytics add-on.

Lowercase filters

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.

1. Lowercase Campaign Name (utm_campaign) values

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.

  • Filter Name: Lowercase – Campaign Name
  • Filter Type: Custom > Lowercase
  • Filter Field: Campaign Name

Lowercase Campaign Name (utm_campaign) values

2. Lowercase Campaign Source (utm_source) values

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.

  • Filter Name: Lowercase – Campaign Source
  • Filter Type: Custom > Lowercase
  • Filter Field: Campaign Source

Lowercase Campaign Source (utm_source) values

3. Lowercase Campaign Medium (utm_medium) values

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.

  • Filter Name: Lowercase – Campaign Medium
  • Filter Type: Custom > Lowercase
  • Filter Field: Campaign Medium

Lowercase Campaign Medium (utm_medium) values

4. Lowercase Campaign Term (utm_term) values

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.

  • Filter Name: Lowercase – Campaign Term
  • Filter Type: Custom > Lowercase
  • Filter Field: Campaign Term

Lowercase Campaign Term (utm_term) values

5. Lowercase Campaign Content (utm_content) values

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.

  • Filter Name: Lowercase – Campaign Content
  • Filter Type: Custom > Lowercase
  • Filter Field: Campaign Content

Lowercase Campaign Content (utm_content) values

6. Lowercase Internal Site Search Terms

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.

  • Filter Name: Lowercase – Search Term
  • Filter Type: Custom > Lowercase
  • Filter Field: Search Term

Lowercase Internal Site Search Terms

7. Lowercase Page Paths

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.

  • Filter Name: Lowercase – Page Path
  • Filter Type: Custom > Lowercase
  • Filter Field: Request URI

Lowercase Page Paths

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.

Bonus: If you would like to save time, you can easily download all the “Lowercase Filters” described in this article to your Google Spreadsheet document, make necessary changes there, and import what you need to your desired Google Analytics account using the Filter Management for Google Analytics add-on.

Search and Replace filters

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.

1. Combine all Facebook sources in one

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:

  • Filter Name: Search and Replace – Combine all Facebook sources in one
  • Filter Type: Custom > Search and Replace
  • Filter Field: Campaign Source
  • Search String: (^|.*.)facebook.com$|^facebook$
  • Replace String: facebook.com

Combine all Facebook sources in one

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:

2. Combine all Instagram sources in one

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:

  • Filter Name: Search and Replace – Combine all Instagram sources in one
  • Filter Type: Custom > Search and Replace
  • Filter Field: Campaign Source
  • Search String: (^|.*.)instagram.com$|^instagram$
  • Replace String: instagram.com

Combine all Instagram sources in one

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.

3. Combine all Pinterest sources in one

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:

  • Filter Name: Search and Replace – Combine all Pinterest sources in one
  • Filter Type: Custom > Search and Replace
  • Filter Field: Campaign Source
  • Search String: (^|.*.)pinterest.(.*)|^pinterest$
  • Replace String: pinterest.com

Search and Replace Combine all Pinterest sources in one

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.

4. Combine all Twitter sources in one

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:

  • Filter Name: Search and Replace – Combine all Twitter sources in one
  • Filter Type: Custom > Search and Replace
  • Filter Field: Campaign Source
  • Search String: (^|.*.)twitter.com$|^t.co$|^twitter$
  • Replace String: twitter.com

Combine all Twitter sources in one

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.

5. Combine all LinkedIn sources in one

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:

  • Filter Name: Search and Replace – Combine all LinkedIn sources in one
  • Filter Type: Custom > Search and Replace
  • Filter Field: Campaign Source
  • Search String: (^|.*.)linkedin.com$|^lnkd.in$|^linkedin$
  • Replace String: linkedin.com

Combine all LinkedIn sources in one

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.

6. Remove all Query Parameters from Page Paths

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:

  • Filter Name: Search and Replace – Remove all Query Parameters from URLs
  • Filter Type: Custom > Search and Replace
  • Filter Field: Request URI
  • Search String: ?.*
  • Replace String: (leave it blank)

Remove all Query Parameters from Page Paths

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:

7. Simplify Page Paths

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/”:

  • Filter Name: Search and Replace – Remove “/directory/” from the page path
  • Filter Type: Custom > Search and Replace
  • Filter Field: Request URI
  • Search String: /directory/
  • Replace String: /

Simplify Page Paths

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:

8. Consolidate your Hostnames (domains)

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”:

  • Filter Name: Search and Replace – Consolidate www.yourdomain.com and yourdomain.com Hostnames
  • Filter Type: Custom > Search and Replace
  • Filter Field: Hostname
  • Search String: ^www.
  • Replace String: (leave it blank)

Consolidate your Hostnames (domains)

Note: You can find all hostnames, if you open: Audience > Technology > Network > Hostname (Primary Dimension) report in your Google Analytics account.

Extra reading materials:

9. Replace numbers with names in Page Paths

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:

  • Filter Name: Search and Replace – Replace “sexId=1&” with “sexId=woman&” in page paths
  • Filter Type: Custom > Search and Replace
  • Filter Field: Request URI
  • Search String: sexId=1&
  • Replace String: sexId=woman&

Replace numbers with names in Page Paths

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:

  • Filter Name: Search and Replace – Replace “sexId=1” with “sexId=woman” in page paths
  • Filter Type: Custom > Search and Replace
  • Filter Field: Request URI
  • Search String: sexId=1$
  • Replace String: sexId=woman

Replace numbers with names in Page Paths 2

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:

10. Remove .html from Page Paths

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:

  • Filter Name: Search and Replace – Remove .html from Page Paths
  • Filter Type: Custom > Search and Replace
  • Filter Field: Request URI
  • Search String: .html
  • Replace String: /

Remove .html from Page Paths

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:

Bonus: If you would like to save time, you can easily download all the “Exclude Filters” described in this article to your Google Spreadsheet document, make necessary changes there, and import what you need to your desired Google Analytics account using Filter Management for Google Analytics add-on.

Advanced filters

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.

1. View Full Page URL instead of Page Path

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:

  • Filter Name: Advanced – View Full Page URL (Hostname + Request URI)
  • Filter Type: Custom > Advanced
  • Field A: Hostname
  • Extract A: (.*)
  • Field B: Request URI
  • Extract B: (.*)
  • Output To: Request URI
  • Constructor: $A1$B1
  • Field A Required: Select
  • Field B Required: Do not select
  • Override Output Field: Select
  • Case Sensitive: Do not select

View Full Page URL instead of Page PathNote:

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:

2. Rewrite Medium from “referral” to “social” for Social sources

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:

  • Filter Name: Advanced – Rewrite Medium from “referral” to “social” for Social Sources
  • Filter Type: Custom -> Advanced
  • Field A: Campaign Source
  • Extract A: linkedin|facebook|stumbleupon|t.co$|reddit|quora|stackoverflow|lnkd.in$|twitter|instagram|youtube|pinterest
  • Field B: Campaign Medium
  • Extract B: referral
  • Output To: Campaign Medium
  • Constructor: social
  • Field A Required: Select
  • Field B Required: Select
  • Override Output Field: Select
  • Case Sensitive: Do not select

Rewrite Medium from “referral” to “social” for Social sources

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:

3. Remove text before the pipe in all Page Titles

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:

  • Filter Name: Advanced – Remove text before the pipe in all Page Titles
  • Filter Type: Custom > Advanced
  • Field A: Page Title
  • Extract A: ^(.*)|(.*)$
  • Field B: (do not select anything)
  • Extract B: (leave it blank)
  • Output To: Page Title
  • Constructor: $A2
  • Field A Required: Select
  • Field B Required: Do not select
  • Override Output Field: Select
  • Case Sensitive: Do not select

Remove text before the pipe in all Page Titles

Note: You can simply replace pipe (|) with the dash (-) or colon (:) in the “Extract A” field if needed.

Extra reading materials:

4. Remove All Query Parameters from Page Paths

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:

  • Filter Name: Advanced – Remove All Query Parameters from Page Paths
  • Filter Type: Custom > Advanced
  • Field A: Request URI
  • Extract A: (.*)?
  • Field B: (do not select anything)
  • Extract B: (leave it blank)
  • Output To: Request URI
  • Constructor: $A1
  • Field A Required: Select
  • Field B Required: Do not select
  • Override Output Field: Select
  • Case Sensitive: Do not select

Remove All Query Parameters from Page Paths

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:

5. Append Slash to Page Paths

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:

  • Filter Name: Advanced – Append Slash to Page Paths
  • Filter Type: Custom > Advanced
  • Field A: Request URI
  • Extract A: ^(/[a-zA-Z0-9/_-]*[^/])$
  • Field B: (do not select anything)
  • Extract B: (leave it blank)
  • Output To: Request URI
  • Constructor: $A1/
  • Field A Required: Select
  • Field B Required: Do not select
  • Override Output Field: Select
  • Case Sensitive: Do not select

Append Slash to Page Paths

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:

6. Remove Slash from Page Paths

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:

  • Filter Name: Advanced – Remove Slash from Page Paths
  • Filter Type: Custom > Advanced
  • Field A: Request URI
  • Extract A: ^/(.*?)/+$
  • Field B: (do not select anything)
  • Extract B: (leave it blank)
  • Output To: Request URI
  • Constructor: $A1
  • Field A Required: Select
  • Field B Required: Do not select
  • Override Output Field: Select
  • Case Sensitive: Do not select

Remove Slash from Page Paths

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:

7. Set up Site Search for Nonstandard Search Results URL

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:

  • Filter Name: Advanced – Site Search for Nonstandard Search Results URL
  • Filter Type: Custom > Advanced
  • Field A: Request URI
  • Extract A: ^/search/(.*)
  • Field B: (do not select anything)
  • Extract B: (leave it blank)
  • Output To: Search Term
  • Constructor: $A1
  • Field A Required: Select
  • Field B Required: Do not select
  • Override Output Field: Select
  • Case Sensitive: Do not select

Set up Site Search for Nonstandard Search Results URL

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:

8. Remove Subdirectories and Dynamic IDs from Page Paths

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:

  • Filter Name: Advanced – Remove “/configure/id/” and Dynamic IDs from Page Paths
  • Filter Type: Custom > Advanced
  • Field A: Request URI
  • Extract A: ^(/checkout/cart/)(configure/)(id/)(d+)(.*)
  • Field B: (do not select anything)
  • Extract B: (leave it blank)
  • Output To: Request URI
  • Constructor: $A1{IDs}$A5
  • Field A Required: Select
  • Field B Required: Do not select
  • Override Output Field: Select
  • Case Sensitive: Do not select

Remove Subdirectories and Dynamic IDs from Page Paths

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:

Bonus: If you would like to save time, you can easily download all the “Advanced Filters” described in this article to your Google Spreadsheet document, make necessary changes there, and import what you need to your desired Google Analytics account using Filter Management for Google Analytics add-on.

Summary

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. ????????????

Menu
73 Shares
Share
Share
Pocket
Buffer
Tweet