Installing Analytics And Creating Filters



Filters are important, aren’t they? Well, don’t get confused with the image above (Though I love that cocktail), We are going to talk about Google Analytics Filters today.

In case you didn’t notice, we wrote about Goals previously which was so well taken.

First thing first, you must have edit access to create view filters in Google Analytics. Once you have that, Click on Admin, and then on Filters. To create a filter, click on “+Add Filter”. Filters in Google Analytics can be set up to exclude, include, or filter specific data in your Analytics reporting. For example, you can create a filter that excludes your editor's Internet Protocol (IP) address if they visit your website daily to make changes. Users can create properties, views, filters, goals, etc. It’s a great option for strategy-focused members of your team. Collaborate: Collaborators can create and manage personal assets within Google Analytics, but are unable to make changes on an administrative level.

A Step By Step Guide To Goals In Google Analytics https://t.co/hwh5fjVwcE /by @ukhost4u#measurepic.twitter.com/LqtNYRUEy9

— Google Analytics (@googleanalytics) August 31, 2018

Talking about Google Analytics filters, they are something we all have dreaded at some point of time.

But not anymore!

In this guide I am going to walk you through the step by step guide to create Google Analytics filters. While talking about various types of GA filters, we will also have a look on the most useful filters for a website owner.

So all set to start your journey? Let’s not delay it then!

What are Filters?

By default Google Analytics collects the data of all of your visitors. This vast amount of data can often confuse you on which data is actually relevant for your business. Or if I say in better words, what if you want subset of this data for better decision making?

Well, filters are your savior here.

GA filters are a way to ensure that your reporting includes or excludes some specific data based on your requirements.

Let me explain it with an example.

Has it ever happened to you while looking at your GA reports

Installing
  • You wished some of your data wasn’t there?
  • You wanted to exclude your internal traffic to be included in GA reports?
  • Perhaps you wanted to get data for a specific subdomain of your website?

Filters are the answer to all of these questions.

With filters, you can create specialized views. These are solely focused on the specific sections of your website traffic. This gives you the privilege to modify or filter the kind of data GA is collecting.

But before we go further, let’s go through some of the terms. Knowing these will help you better understand the concept.

View Filters:

  • Google Analytics allows you to create view filters within Admin.
  • Creating these filters requires you to have edit-level access.
  • The effect on the data is permanent, which means data once lost can’t be retrieved.
  • Allow you to create filters on dimension, not only metrics.

Table Filters:

  • Table filters are the one created in reporting environment.
  • Anyone can create these filters, no edit-level access required.
  • These filters affect the data temporarily.
  • With some advanced table filters, you can apply these filters on any combination of dimension and metrics.
  • These are often used to brainstorm your data without any permanent effect.

Segments:

  • Any user can set-up segments.
  • Unlike filters, they affect historical data not the upcoming one.
  • These are used for short term segmentation like ad-hoc analysis.

Views in Google Analytics:

Filters can be easily applied on one or more views. But before that, let’s understand the best practices of creating views in GA. Ideally, there should be three views in your GA account:

Primary reporting view:

This is the view where you are going to apply the filter. The data provided by this view will be more accurate and personalized.

Raw reporting view:

Since there is no way to reverse a filter and its effect is permanent, you must have a backup for your data. This view will be your backup. The data collected by this view will be free of any filters and collect all of the data.

Test reporting view:

Before applying any filter to your primary view, you must test it. This view will be used to test out your filters and once you are sure that they are working fine, you can apply it to primary view.

Now that you have clear idea about views in GA, I recommend always test your filter before applying it to primary view. There is no UNDO when it comes to GA data.

Setting up filters in Google Analytics:

First thing first, you must have edit access to create view filters in Google Analytics.

Once you have that,

  • Click on Admin, and then on Filters.
  • To create a filter, click on “+Add Filter”.

A new configuration screen will open up in front of you.

Here you will have to name your filter. Choose the name wisely as it will save you from any confusion in future.

Next you will have to choose among the two types of filters-

Installing Analytics And Creating Filters Amazon

  1. Predefined
  2. Custom

We are going to talk about these types in details in the next section.

Once your filter creation is over, you can verify this filter to see if it is working fine and then click on “Save” and you are done. Isn’t it, simple?

PS. As I have already mentioned above, always create your filter first in “Test view” and if it works fine, then only apply it on “Primary view”.

Step 1: Pre-defined Google Analytics Filters:

Predefined GA filters are quite easy to deal with and you can create your own in minutes. There are three options it provides here.

  1. Filter Type
    1. Exclude
    2. Include Only
  2. Source or destination
    1. Traffic from the ISP domain
    2. Traffic from the IP domains
    3. Traffic to the subdirectories
    4. Traffic to the hostname
  3. Expression
    1. That are equal to
    2. That begin with
    3. That end with
    4. That contain

As you can see in above table here you have to choose from 32 filters. You can include or exclude any of the following dimensions:

Filter for ISP domain:

If you are a large organization with your own Internet service provider (ISP), you need to use this filter. This ISP domain filter helps you to filter your data on the basis of your domain ISP. You can find your ISP here.

To create this filter you need to mention your ISP domain and click on save and you are done.

PS. If you don’t have your own ISP, don’t use this filter otherwise you will end up filtering other people’s visits too. In that case, you can use IP address filter that we are going to discuss next.

Filter for IP address:

Generally, we don’t want to analyze visits from our own organization. These visits can come from our marketers, developers, etc and can really ruin own data.

For eg, if you have an eCommerce website, and you want to test your checkout process, you don’t want to analyze fake test purchases by your own QA people.

To create this filter, you need to find your IP address. You can find it by Googling “What’s my ip”. For smaller organizations, it is usually just one internal IP address.

Let’s say your IP address is 78.145.201.548, you need to add this address in the section and click on “Save”.

Although, most of the companies use IP ranges. Here’s when regular expressions come into the picture.

Let’s say your IP range is 79.205.34.0 – 79.205.34.15.

Use this tool here.

The filter for this purpose would look like below:

This IP range filter is created using “Custom” filters which we are soon going to discuss.

Filters for sub-directories:

Let’s look at our own website ukhost4u.

Now let’s look move over to the blog section and analyze blog structure.

As we can see, all of the blogs lie in the subdirectory /community/blog/ .

What if we want to provide only the blog analytics access to specific people. What we will do is we will create a view and apply Subdirectory filter here. I will tell you how.

  • Choose the option “Include Only”.
  • In the second option, click on “Traffic to the subdirectories”.
  • In the third option, click on “that begin with”.
  • Lastly, provide your Subdirectory and click on save.

In the above example, here’s how our filter would look like.

Filter for Host Name:

Let’s say, your website is mydata.com and another website has intentionally/accidentally copied your tracking code for their website. Now you’re getting all mixed up data.

Here you are going to need this filter. All that you have to do is to choose “Hostname” filter and provide your website here, as shown in the image below.

This filter will help you fight spam while also prevent someone else from stealing your tracking code.

Step 2: Custom Filters

Here you will find five main categories of the filters:

  • Exclude
  • Include
  • Lowercase
  • Uppercase
  • Search and Replace
  • Advanced

Exclude/Include filter

This comes with endless possibilities. The major categories of these filters are:

  1. Content and traffic
  2. Campaign or adgroup
  3. E-commerce
  4. Audience/Users
  5. Location
  6. Event
  7. Other
  8. Application
  9. Mobile device
  10. Social

I will writing on these in upcoming articles here at ukhost4u.

Lowercase/Uppercase filter

We all know that Google considers an uppercase letter and a lowercase letter as two different characters.

Now let’s say you are using UTM parameters for tracking. But the problem is:

  • Matt has tagged his UTM content as video
  • Ryan has tagged UTM content as Video

In this case, GA will consider it as two different media when it comes to email campaigns and it can ruin your data in multiple ways.

To make this data more neat, you can use these uppercase/lowercase filters. Usually I prefer to keep everything in lowercase.

So here’s how we will create filter in above case.

It will fix all the issues of capital letters as the UTM content will be video now.

Let’s take another example here. A user uses search function on your website to find “SEO” while the other one uses “seo”. Here you will have to add lowercase filter to “Search terms”.

Some of the areas where you should put lowercase filters are:

  1. Campaign medium
  2. Campaign content
  3. Campaign source
  4. Campaign name
  5. Campaign term
  6. Request URI

Note: Except location based filters, uppercase and lowercase filters can be applied everywhere.

Search and replace filter

Are your Google Analytics report include unreadable identifiers or codes that don’t make any sense at all?

For eg, you have set events for contact form submissions as contact_form_115. But you can easily search and replace it with something more readable say, Contact form in analytics reports.

Here’s how the filter will look like

Advanced filters

For these filters, you need to get hold on regular expressions. With advanced filters, you are able to combine multiple fields into variables.

One of the most common use-case of these kind of filters is get host name into reports. Typically, GA doesn’t show host name in reporting. But what if, you want the host name to be displayed in reports which is useful when you have multiple sub domains and you want to analyze the traffic within sub domains.

Here’s the filter we are going to use and then we will see how it works.

Here with field A, we have collected the Hostname and with field B, we have collected the URI and combined them into output.

So now instead of data like this

/community/blog/ssd-vs-hdd-hosting-which-should-you-choose/

We will get data like this:

There are multiple possibilities how you can use these advanced filters to create a more specific view for your business.

Step 3: Google Analytics Filter Order:

While you have understood various types of filters, you must understand how they are processed. Here you need to understand about Filter Order.

Filter order is nothing but the sequence in which your filters are going to be applied. Usually filter order doesn’t matter if you are dealing with different aspects of your data. But if you are altering the same kind of data multiple times, filter order is something that matters.

Let’s understand this with a simple example below.

Below I have created an include filter for a specific section on my website.

Filter 1: Include only Marketing blog section of the website

This filter will alter my data so that only following kind of pages will show up in my reports:

/mblog

/mblog/post1

/mblog/post2

Etc..

Filter 2: Include complete URL

This will alter the output of above filter and now the data will show up like this:

Creating

www.domain1.com/mblog

www.domain1.com/mblog/post1

www.domain1.com/mblog/post2

So what’s wrong?

Nothing, I say! But try changing the filter orders for above filters and you will see there is no data.

Wondering why? Let’s analyze here.

The first filter will be now about adding complete URLs, so your data would look like:

www.domain1.com/mblog

www.domain1.com/eblog

www.domain1.com/vblog

Everything is fine until here but when the second filter is be applied, it won’t work. Let me tell you why.

With second filter regex, you intend to match /mblog with a URL that starts with /, but we have already changed it to www.domain.com/mblog in previous filter. So there won’t be any match and thus, won’t be any ata.

So your next question is, how do I change the filter order?

  • Click on your “Filters” list.
  • Click on “Assign Filter Order”.

With the help of move up and move down buttons, now you can change the filter orders.

Click on Save and you’re done 🙂 To verify this filter, make use of “Real time data”.

Benefits of Google Analytics Filters:

GA filters can help a business in numerous ways. But let’s analyze the major reasons, filters are important for you.

Data security

Let’s say, you want to provide access of the blog section to your editor. You want to make sure editor only views the traffic data of the blog section. Here, you can easily create a view filter that collects data only for the blog section and provide access to your editorial team. This way rest of your data is safe and not accessible to all.

Better convenience

Yes, you can always use segments to get specified data. But if you need to look at this data on regular basis, filters can come to your rescue. Also, for someone who is not that expert in Google Analytics, all that you need to do is to create a view with right filter and provide them the access. Simple as that!

Include/exclude specific IP address

If you have an organization with hundreds of employees, internal traffic can really ruin your data. As segments don’t allow you to include or exclude specific IP addresses, view filters is the only way out.

Lastly, filters ensure you get the data that you really need and there are endless possibilities when it comes to filters. So what are you waiting for? Get started now!

Some pointers to keep in mind while using filters

  • There is no undo for Google Analytics filters, so choose your filters carefully.
  • Before applying filters on primary view, make sure to test it on test view first.
  • Always have a backup data view which is completely unfiltered.
  • Don’t freak out if your new filters don’t start working, it usually takes around 2 hours for them to work after the set-up.
  • If you are working with custom or advanced filter, always keep the filter processing order in mind for right results.
  • No matter which niche you belong to, filters are something that would make your data more accurate, helping you take data driven decisions.

Which filters to avoid?

Although filters might excite you, but existence of table filters and segments imply that you don’t always need view filters to get the specific data. In some cases, it is indeed better to use “segments” over “view filters”. Below are some of the situations where you should try to avoid using GA filters:

  • Don’t create include/exclude filters for specific geo locations. You can easily get that data with the help of segments.
  • Don’t create include/exclude filters for campaign tags.
  • Creating filters to find out the devices people are browsing your website from, is not necessary.

What I am trying to say is that, yes filters are extremely important to get customized data. But you must understand that they permanently modify your data. So choose your filters very carefully.

This article shows how to add smart filter widgets to your SQL questions in Metabase using a special type of variable called a Field Filter.

Introduction to Field Filters

For Metabase questions written in SQL, we can use basic variable types — Text, Number, and Date variables — to create simple filter widgets. To create “smarter” filter widgets that can display options specific to the data in the filtered column, such as to create a dropdown menu of values, we can use a special variable type called a Field Filter.

Field Filters can initially confuse some people, because 1) Field Filters only work with certain fields, and 2) people expect Field Filters to behave like basic input variables (which they don’t).

Field Filters are well worth learning, as you can use them to create much more sophisticated filter widgets. In this article, we’ll go through Field Filters in depth, but first let’s discuss the main practical differences that distinguish Field Filter variables from basic Text, Number, and Date variables.

Distinguishing Field Filters from simple Text, Number, and Date variables

  1. Field Filters are optional by default. If no value is given, the SQL query will run as if the Field Filter didn’t exist. You do, however, have the option to require a value.
  2. Field Filters won’t work with table aliases. Since Field Filters rely on metadata about columns in your tables (and the specific names of those tables), the filters can’t “know” that you’ve aliased a table. And depending on the database you’re using, you may need to include the full schema path in the FROM clause.
  3. Field Filters use a special syntax so they can handle SQL code behind the scenes. You simply supply a Field Filter to a WHERE clause (without a column or operator), and the Field Filter will manage the SQL code for you, which allows the code to account for multiple selections people make in the filter widget.

Point #3 can be especially confusing, so let’s unpack it with an example.

Creating a filter widget with a dropdown menu

We’ll use the Sample Dataset included with Metabase to add a filter widget with a dropdown menu to a question written in SQL.

Let’s say we want to create a SQL question that grabs all the orders from the orders table, but we want to give people the option to filter the results by category in the products table.

Now, we could create a products.category filter with a basic input variable, like so:

In this case, we enclose the WHERE clause in double brackets to make the input optional, and use the Variables sidebar to set the Variable type to Text and the Filter widget label to Category.

This approach works, but it’s not ideal:

  • In order to filter the data, people would have to know which categories exist (and spell them correctly when they input them).
  • Plus, they can’t select multiple categories at a time, as the {{category}} variable only accepts a single value.

Installing Analytics And Creating Filters Effective

By contrast, a Field Filter will map the variable to the actual column data. The filter widget connected to the variable then “knows” which categories are available, and can present a dropdown menu of those categories, like so:

A word on the widget: the dropdown menu is just one of the options available. In the case of fields of type Category, like our category field in the products table, we could also set the filter widget as a Search box or a Plain input box. Admins can configure Field settings in the Data Model page of the Admin Panel.

Note that Metabase will automatically use a Search box if the number of distinct values in the column is greater than 300, even if you select the dropdown option, A list of all values. Learn more about editing metadata in our documentation.

Installing Analytics And Creating Filters

Now, let’s get back to our question. Here’s the syntax for the products.category Field Filter. And note the omission of the column and operator before the variable in the WHERE clause – more on Field Filter syntax below:

With our variable in place in the WHERE clause, we can use the Variables sidebar to wire up our variable as a Field Filter. We’ll set:

Installing
  • Variable type to Field Filter.
  • Field to map to to Products -> Category. This setting tells Metabase to connect the variable in our SQL code to the category column of the products table.
  • Field widget type to category.
  • Field widget label to category.

We won’t require the variable, so no default value is necessary. If the query runs without a specified value in the filter widget, the query will return records from all categories.

Note that the WHERE clause does not specify which column the variable should be equal to. The reason for this implicit syntax (the hidden SQL code) is so that the Field Filter can handle the SQL code behind the scenes to accommodate multiple selections.

Creating sophisticated date filter widgets

We can create a basic input variable of type Date, which will add a filter widget with a simple date filter. If, instead, we use a Field Filter variable, we can connect that variable to a field (column) that contains dates, which unlocks a lot more options for configuring our filter widget.

Here are the different widget types for Field Filters mapped to Date fields:

  • Month and Year
  • Quarter and Year
  • Single Date
  • Date Range
  • Relative Date
  • Date Filter

Each widget type offers different ways for people to filter the results: Here are three examples:

The Date Filter widget type offers the most flexibility, allowing people to filter by relative dates and ranges.

Field Filter gotchas

There are a few places that people typically get stuck when trying to implement Field Filters.

Field Filters are incompatible with aliasing

As noted above, Field Filters won’t work if you use aliases in your SQL query. For example, this code (with aliases) will not work:

AVOID

Whereas this code without aliases WILL work:

CORRECT

The reason is because Field Filters work by analyzing metadata about your data (e.g., the column names of your tables), and that metadata does not include the aliases you create in your SQL code. Note that some databases require the schema in the FROM clause. An example for Oracle would be FROM 'schema'.'table'. In BigQuery, back ticks are needed: FROM `dataset_name.table`.

Omit the direct assignment in the WHERE clause

As stated above: the SQL code around Field Filters is not exactly street legal. You may be tempted to write:

AVOID

because, in standard SQL, that is the correct syntax for a WHERE clause. But that syntax won’t work for Field Filters.

The correct syntax for Field Filters omits the = operator:

CORRECT

The reason for this shorthand is so that Metabase can, behind the scenes, handle the SQL code for situations like multiple selections, e.g., when a user selects multiple categories from a dropdown.

Only certain fields are compatible with Field Filters

Here is the list of compatible fields.

You can find a list of incompatible field types in our documentation on Field Filters.

Learn more

Check out our guide to basic SQL input variables - Text, Number, and Date.

You can also read our documentation on: