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


About the Author

Joe Schaefer

Joe Schaefer is the owner of Untypical Marketing.


3 thoughts on “11 Pipers Piping: An Introduction to Regular Expressions and Pipes


  • Kaila S on said:

    Great post Joe. Regular expressions are so hard for many, including myself, but you’ve done a great job of explaining how to use and implement pipes. Thanks!


    • Joe Schaefer on said:

      Thanks Kaila! It’s a difficult subject, that’s for sure. I think it just takes time, getting the basics down and then building yourself up slowly to the more complicated patterns (and that might mean some trial and error!).


  • Ned Wells on said:

    Hi Joe, just wanted to say thank you for putting together such a lucid post on RegEx. I’ve known about them for a while but not explored them very much to date. You’ve written a simple post on a subject that I’ve previously thought of as complicated, and it’s encouraged me to delve more into the subject. All the best for 2012.


Leave a Reply

Your email address will not be published.

*


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Comments links could be nofollow free.