Using Filters to Create GA Reports for Each Section of Your Site

Paul Koch, Former Data & Analytics Director

Article Categories: #Strategy, #Data & Analytics

Posted on

Recently, Matthew came to us with a common Google Analytics challenge--how to break out reports for particular sections of a site. He wrote a blog post explaining his situation, and we helped out--here’s how we did it, so you can, too!

The Challenge

In Matthew’s example, the site contains apartment listings that always begin with bozzuto.com/apartmentname and end with the name of the apartment’s specific page, such as bozzuto.com/apartmentname/features or bozzuto.com/apartmentname/floor_plans. We want to get GA reports broken down by apartment, so only that apartment’s pages show up in the reports.

Here were a few solutions Matthew had previously tried that weren’t successful:

  • A profile with /apartmentname as the index page. This doesn’t work because the Index Page doesn’t include or exclude any data. It’s intended for consolidating URLs to the same page, such as combining /page1 and /page1/index.html, so they don’t show up as multiple line-items in your reports. The feature can’t isolate a specific subset of traffic, so we should scratch it as a solution.
  • An advanced segment where the page contains /apartmentname. Advanced segments can be a great option for slicing and dicing your traffic, but unfortunately, they don’t work here. Advanced segments apply at the session level, so “page containing /apartmentname” actually means “any visit that included a stop on an /apartmentname page.” If you also visited other pages in the course of your visit, those pages will show up in the content report with this segment applied.
  • A custom report. With GA’s v5 interface, a custom report could actually isolate all traffic to pages matching a particular initial URL--but you’re limited to the report you’ve built. What if you want to easily look at all your reports--keywords, referring sites, or other sources that led people to those pages--for example? We need a solution that give us all of GA’s awesome standard reports, too!

The Solution--Profile Filters

Profile-level filters are the perfect solution. I’ve written about filters before because I love the flexibility it gives me as a non-developer to manipulate my data. Filters can include, exclude, or re-write certain sets of data before it appears in your reports. If you’re totally unfamiliar, take a look at this good Google explanation first.

The premise of what we want to do is simple. Using Matthew’s example: Part 1: Show only traffic for pages that start with: http://bozzuto.com/apartments/communities/77-the-fitzgerald-at-ub-midtown. Part 2: Cut off that first part of the URL, so that in the content reports, you only see “/”, “/features”, or “/floor_plans”, and not the long, messy URL.

Filter #1 -- Include .*/apartments/communities/77\-the\-fitzgerald\-at\-ub\-midtown.*

“Include” filters exclude anything you don’t specifically include. So by including /apartments/communities/77-the-fitzgerald-at-ub-midtown, any URL that doesn’t contain that string won’t show up in a report with this filter.

What’s with the backlashes and the .* in the filter? The .* is a regular expression combination signifying “anything”. Putting it at the beginning and end of the filter pattern means that other text can come before or after the URL, as long as /apartments/communities/77-the-fitzgerald-at-ub-midtown is somewhere in the string. The backslashes tell GA not to treat the next character as a regular expression. Normally, when GA sees a dash, it thinks you’re using the “range” regular expression--so if you have dashes in your URL, stick a “\” before each one in the filter.

Filter #2 -- Shorten the URL

If we’re in “The Fitzgerald” profile, we don’t need the longer, messier URL, so let’s lob off the first part (mouse over the image to expand).  

In the picture, the “Field A → Extract A” value is /apartments/communities/77\-the\-fitzgerald\-at\-ub\-midtown(.*)

This filter says to pick up the value of whatever comes after /apartments/communities/77-the-fitzgerald-at-ub-midtown and then over-write the URL to show only that content, preceded by a slash.Why do we add a “/” before the “Output To → Constructor” field? We have to account for the apartment’s homepage. Otherwise, the /apartments/communities/77-the-fitzgerald-at-ub-midtown would disappear from the GA reports, unless something was on the end of it. With our filter, the apartment’s homepage will appear simply as “/” (like the homepage usually does in standard GA reports).

Filter #3 -- Remove double slashes

Because we stuck that extra slash in the filter above, can you think what problem that will cause? What if my URL is /apartments/communities/77-the-fitzgerald-at-ub-midtown/floor_plans? The previous filter will output the URL as //floor_plans. Yuck. Let’s remove that double slash:

This filter says, “pick up any URL that starts with //, take whatever comes after the two slashes, and re-write the URL to have a single slash, followed by that text string.”That’s it--just make a separate profile for each individual site section you want to measure. In our example, the final product is a profile called “The Fitzgerald” with a content report that looks like this:

I’m no designer, but that looks mighty pretty to me. :)

If you have other questions about profile structures or filters, please ask in the comments.

Related Articles