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


Table Filters are Interpreted as Regular Expressions, So You Must “Escape” Question Marks

Table Filter Interpreted as Regular Expressionview at full size

Table filters are interpreted as regular expressions.

Though it’s not indicated anywhere in the interface, the table filter field in Google Analytics reports is interpreted as a regular expression (or “regex” for short).

In regex notation, there are two types of characters: literal characters and metacharacters. If you’re trying to filter your Pages report to display pages that contain article.aspx?id=, you must “escape” the question mark with a \ character so the ? acts as a literal character. Otherwise, the ? will be interpreted as metacharacter – specifically, a quantifier meaning zero or one of the previous character.

To further illustrate, if you enter article.aspx?id= into the filter field, you’ll match any pages that contain article.aspid= or article.aspxid=, but not article.aspx?id=, since the question mark is interpreted as a regular expression metacharacter and not as a literal. If you enter article.aspx\?id= into the filter field, you’ll match any page that contains article.aspx?id= since the question mark is now interpreted literally.

By escaping the question mark, we “escape” interpretation of the character following the \ as a regex metacharacter and allow it to act as a literal character.

Note as well that in proper regex notation, all literal . characters are also escaped so they’re not interpreted as the wildcard metacharacter that matches any single literal character. The filter article.aspx\?id= would also match pages that contained articlesaspx?id= and article-aspx?id= because the . is acting as a metacharacter. To restrict the match to article.aspx\?id=, you’d need to also escape the . as in article\.aspx\?id= and thereby force the . to be interpreted literally.

Don’t feel that you need to memorize regular expression notations. Know the principles, and download a cheat sheet at: http://www.e-nor.com/blog/google-analytics/google-analytics-regex-and-keyboard-shortcuts-desktop-backgrounds

Please share this post:
Facebook Twitter Plusone Linkedin Email

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>