Web Analytics World

Analytics, Mobile, Social Media and Digital Marketing Strategy

  • Home
  • About Us
  • Digital Marketing Courses
    • Digital Marketing Professional Certificate
    • MSc Digital Marketing Online
  • Current Bloggers
  • Contact Us
You are here: Home / Google Analytics / Six Powerful Ways to Apply Regular Expressions in Google Analytics

Six Powerful Ways to Apply Regular Expressions in Google Analytics

March 1, 2016 by Paul Koks 1 Comment

Image of ocean wave with text "6 powerful ways to use RegEx in Google Analytics"For most Google Analytics users, including web analysts, regular expressions can be daunting. However, even a basic understanding can greatly help you on your path to master Google Analytics.

In this blogpost I will share why you want to know more about regular expressions and where to apply them in your Google Analytics account.

I am sure that following my tips will greatly improve your Google Analytics set up and analysis. Let’s take a brief look at the main list of regular expressions:

regular-expression-cheat-sheet

Regular expressions are characters than help you define, include or exclude data in Google Analytics. Every time I visit the Google Analytics forum to provide help, I see many questions popping up about regular expressions.

There are (at least) six different cases where they really come in handy:

  1. Creating filters in admin section
  2. Applying table filters
  3. Setting up (destination) goals
  4. Defining a goal funnel
  5. Creating segments
  6. Creating custom reports

In my opinion, these are all vital features of Google Analytics. If you get them wrong both your data reliability as well as insights will suffer.

1. Creating Filters in Admin

As you might know, filters determine what data is collected in each of your views.

In an earlier post, I wrote about six data views you should always set up.

When setting up filters, one of the best practices is to filter traffic on your IP since it pollutes the data in your account.

Here is how the filter looks like:

Regex - filtersThis regular expression ensures that I only filter out my IP address.

In another situation, let’s assume you have a multiple domain implementation with Universal Analytics measuring www.testA.com and www.testB.com. In this era of *SPAM* traffic you want to use an include filter on your hostnames.

Note: setting up two include filters on hostname will return zero data so you need to set up a filter that includes both hostnames.

This is where regular expressions are your best friend.

Regex - filter 2There are actually many filters that involve regular expressions to set them up correctly.

2. Applying Table Filters in Reports

Google Analytics let’s you filter the data in any way that you want and in this example I will show you a few reports on my marathon website:

Regex - table filters

Not too long ago, the field shown above didn’t accept regular expressions. Happily this has changed.

Let’s assume you only want to include pages that contain running or half. In this case you need to fill in running|half.

Regex - table filters 2Now I will remove the extra “space”.

Regex - table filters 3

As you can see, you have to be very careful when using regular expressions as an extra space or wrong characters lead to incorrect or no results.

Read this table filters guide if you want to learn more about table filtering in general.

3. Setting up Goals

Without well-defined goals you can’t optimize your website. You will probably already guess it, regular expressions are very useful in setting up goals as well! In the past I was always complaining about the goal settings “exact match” and “head match”. Why? Simply because they were confusing for a lot of people … and you know what, they have changed it! 🙂

Regex - goal set up

For example, you sell bicycles and have three category pages:

  • /bikes/men
  • /bikes/women
  • /bikes/kids

These category pages are very important to you and you want to correlate the unique views against traffic sources, destination pages etc.

However, you only want to include “men” and “women” in your goal set up.

Regex goal set up 2Two known regular expressions and a new one (). This helps you to keep the regex length to a minimum and include both “men” and “women” category pages.

Once again, without using regular expression characters you cannot set this up as a (combined) goal.

4. Defining Goal Funnels

I won’t elaborate too much on goal funnels here. You can set up goal funnels for a specific journey on your website and you might need to come up with a regular expressions in some or each of your funnel steps.

One more tip here; below the goal settings you can verify your goal. I recommend always taking this small step if you have already data collected to verify your goal set up. This will ensure your goal set up will work fine.

Verify goal set up

You can also navigate to  Behavior > Site Content > All Pages and use the table filter to verify your goal URL. This only applies to destination page (URL) goals.

By now I hope you realize that regular expressions are so powerful and should be in your Google Analytics arsenal!

Wait! We’re not done … there are 2 more things I like to share.

5. Creating Segments

In my opinion, segments are one of the most powerful features in Google Analytics. They provide you with lots of flexibility to analyze and optimize the main KPIs of any website!

Averages lie so you need to dive deeper. This is when segments are your best friend and again, regular expressions really help you to dig deeper and find insights. 

In the earlier table filter example I filtered my data on pages that include the word “running” or “half”. Now I would like to know which media drive the most traffic to pages that include the word “running” or “half”.

Step 1: Build a segment that includes landing pages with the word “running” or “half”

Regex - segmentStep 2: Navigate to “traffic sources” report in Google Analytics and select medium as first dimension

Regex - segment 2

You could select the “all sessions” segment if you would like to compare the distribution of this segment to what’s happening overall on your website.

This is just a simple example of using regular expressions when defining segments in Google Analytics. They help you to build any segment you will ever need to dig deeper, find insights and improve your business!

6. Creating Custom Reports

Custom reports are great and help you bring together all the metrics and dimensions that are relevant to your business and once again, regular expressions are great in leveraging custom reports.

Here is an example of a custom report with a regex applied:

regex - custom reportIn a custom report you can use regular expressions to filter on the data. It’s great if you have a need to build more advanced custom reports.

Well, this is it from my side. I hope to have encouraged you to use regular expressions on a more regular basis! One more thing … I have put together a thorough guide on regular expressions you might want to checkout as well.

What’s your experience with regular expressions?

It would be great if you share about how you use regular expressions in Google Analytics!

Filed Under: Google Analytics, RegEx Tagged With: filters, google analytics, Regex, Regular Expressions

About Paul Koks

Paul Koks is a passionate Analytics and Optimization Consultant. He is specialized in helping companies to optimize their website and traffic channels. On his website Online-Metrics.com he shares actionable insights and best practices on Google Analytics and Conversion Optimization. Make sure to get a copy of his FREE eBook about Analytics and Optimization. You can connect with him on Twitter or LinkedIn.

Comments

  1. MarketPro, Inc. says

    March 10, 2016 at 1:27 pm

    Thank you! Very helpful and detailed. I wish there were more in-depth tutorials like that.

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Get Your Professional Certificate

 

Never miss another post!

Entering your email address in the field below will subscribe you to our RSS to Email list. This means that when we publish a new post, you'll get an email with a synopsis of the post and links to the full article on this site.

  

You can unsubscribe from this service at any time by following the instructions within the notification email.

Our Popular Posts

  • Top 5 PR Strategies
  • Top 100 Outsourcing Companies in the World
  • Top Exit Page Analysis?
  • The Real Reason for Amazon’s Success
  • 57 Things You Can Do With Gmail
  • 10 Must Track Google Analytics Goals
  • Using UTM Tags To Correctly Identify Traffic Sources In Google Analytics
  • How to Analyze and Report ‘Average Visit Duration’ in Google Analytics
  • Basics of Debugging Google Analytics Code: GA Chrome Debugger and other tools
  • 21 Essential Mobile Metrics for Measuring Success

© 2019 Web Analytics World • Privacy • Cookies