Editor's note:
Thanks for visiting GA Tip of the Day. All of my newer posts are published on the E-Nor blog. Please visit and sign up for updates.
- Eric Fettman


Run Your Regular Expressions Through a Regex Tester

Regexpalview at full size

You can test your regular expressions with a tool such as Regexpal.

Regular expressions, or “regex”, can be very useful within Google Analyitcs, but regex syntax is quite challenging, even for the initiated. Before your deploy your regular expressions, you should take advantage of tools that are designed specifically for regex testing.

 

As a simple example, let’s say that you have individual signup forms for eight different product trials on your website, and that the request URI of each thank-you page is in the following format:

 

/product1/thank-you.php

 

Let’s also say that you want to set up a single signup goal for products 2 and 7, which are closely related.

 

After consulting a regex cheat sheet, you test the following regular expression at regexpal.com:

 

/product(2|7)/thank-you.php

 

Regexpal indicates a match, but when you also notice that it has highlighted the . character in the regex field, you realize that you have forgotten to “escape” the . character with a \ character to make it a literal . and not the regex notation for any single character. You just add \ before . to escape it.

 

/product(2|7)/thank-you\.php

 

Now you have a clean regular expression that will do its job for you as the Goal URL. (Just make sure that you select Regular Expression as your goal Match Type.)

Please share this post:
Facebook Twitter Plusone Linkedin Email

One thought on “Run Your Regular Expressions Through a Regex Tester

  1. Pingback: Check Regular Expressions for Goals as Advanced Filters in the Pages Report | Google Analytics Tip of the Day

Leave a Reply

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

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>