11 Pipers Piping: An Introduction to Regular Expressions and Pipes

December 22, 2011
By Joe Schaefer in SEO

regular expressionsWell, we’re up to the 11th day of Christmas – the ole ‘11 Pipers Piping’. So, no better time than now to talk about the pipe when used as a Regular Expression and how to use it to your Google Analytics advantage.

What are Regular Expressions?

Regular Expressions are text patterns that can contain combinations of alphanumeric and special characters. If you’ve ever had the need to use Wildcards, you’ll recognize the similarity. The text pattern that you create with Regular Expressions (RegEx) is used to match and describe characters and words — think of it as more powerful filtering. Using RegEx in Google Analytics can help merge tech with marketing, taking your data beyond the standard goals and filters available to you in Analytics. Although we’re only talking about the pipe today, know that there are 11 other RegEx symbols that can be used in conjunction with each other in a multitude of combinations to extract really meaningful data.

For SEO, you can use RegEx to create more robust filters, or goals that match multiple pages, and make your funnels more specific. More data, I know, but done right and it’s better data. More meaningful, more important.

An Example

Let’s say you’re optimizing for “Christmas Fruitcake Recipes.” When you look at your organic keyword data in Google Analytics, you get a long list of every phrase that sent traffic to your site during a given period. Now, here’s where it can get more interesting. We can use a regular expression to filter that keyword data to gain even more insight. We’ll use the example I’m talking about to filter our imaginary data using the RegEx known as the pipe.

What is the RegEx Pipe and What Does it Do?

The pipe is probably the simplest RegEx that you’ll use and it simply means ‘or’. Simple as that. If we used the pipe (and why the heck would we) in written English it would look like this:

Have you been naughty | nice

(I intentionally left the question mark off that because that character is a RegEx too. No gain in confusing you from the start).

The above phrase would read “Have you been naughty or nice”

Show Me How to Use This RegEx!

In my example above, I am optimizing for “Christmas Fruitcake Recipes” but I want to only see keyword and organic traffic data for phrases that include ‘fruitcake’ OR ‘recipe’ and keep the rest out of the list. To do so, I’d look at my organic keyword data (remember, at this point it’s just a long list of all phrases that sent traffic) and set my Advanced Keyword Dimension to Matching RegExp and type: fruitcake | recipe. (Remember, the pipe is that character that is most likely above your Enter key). My new list of keywords will now only contain phrases that have ‘fruitcake’ or ‘recipe’ and filter out all the rest. I can now see how much traffic the phrases (with either of those words) are sending organically. Simple, but useful example.

regular expressions and google analytics

I encourage you to learn more about RegEx and then decipher my holiday greeting below! And, if you have a better one, comment and let us know!

Happy (Holidays | (Christ|x )mas) | (Ch|H)anukk?ah | Kwanzaa

[This post is part of our 12 Days of SEO series where we’ll be publishing a different nugget of knowledge related to the sounds of the season. We’ll be updating the 12 Days of SEO page as new posts are published.]

Internet Marketing Conferences
Internet Marketing Conferences

PubCon South Summary – Day Two

on Mar 9 by Michelle Lowery

And before we know it, PubCon is over. Well, it’s not quite over, but by the time you read this…

Online Marketing
Online Marketing

Tell-Tale Signs It’s Time To Fire That Client

on Oct 7 by Lisa Barone

No one wants to have to fire a client. As a consultant or service provider, firing a client makes us…

Social Media
Social Media

How To Avoid Accidental Tweets & Disasters

on Apr 1 by Lisa Barone

Working in social media is great… most of the time. The times when you’re not juggling multiple social accounts and…

^Back to Top