Regular Expression Examples for Google Analytics

Regular Expressions (RegEx) are a great way for you to customize your returned data in reports from Google Analytics. Joe Teixeira, Director of Web Intelligence here at MoreVisibility, has written a number of Analytics Blog posts on the subject, including one from this past January on using RegEx to match variations of a Thank You page or multiple Thank You pages by way of Regular Expression Match. In 2008, he wrote a wonderfully easy to read post filled with examples entitled, “Stuck between a ^ and a $ place.” If you didn’t smile at the title, you may need some help identifying the metacharacters used in Regular Expressions. Metacharacters are symbols that have a special meaning when used in a Regular Expression in Google Analytics. You can read the two blog posts here:

The following graphic pairs commonly used RegEx symbols (metacharacters) with a category based on how they may be used.

Some RegEx symbols may be used as a pair, such as those in the grouping category (parenthesizes, brackets, and curly brackets).

Example of brackets as used to match one specific item in a set:

[Uu]\.[Ss]\.[Aa]\. [Pp]rime [Bb]eef

Matches the following examples:

U.S.A. Prime Beef
U.S.A. prime beef
U.S.A. Prime beef
U.S.A. prime Beef
u.s.a. Prime Beef
u.s.a. Prime beef
U.S.a. Prime beef

(Any result where the U is uppercase or lowercase and followed by a dot which is followed by an uppercase or lowercase S that is also followed by a dot which is followed by an uppercase or lowercase A followed by a dot which is followed by a space which is followed by an uppercase or lowercase P followed by “rime” and a space and an uppercase or lowercase B followed by “eef”! As you can see, Regular Expressions can get complex very quickly. We suggest testing all Regular Expressions to make sure they are returning the data you are expecting.)

Note: This Regular Expression would NOT match “USA Prime Beef” or “U.S.A. PRIME BEEF.”

Some RegEx symbols may take on different meanings depending on how they are used. For example, the carat ^ can be used at the start of a search string or as a negative grouping indicator.

Example of carat as a search string starter:


Matches the following examples:


Example of carat as a negative grouping indicator:


Matches the following examples:

(Anything BUT 0, 1, 2, 3, 4, 5, 6, 7, 8 or 9)

So why do you need to know any of this? Knowing how to write Regular Expressions allows you to customize Google Analytics to specifically meet your analytical needs.

You could use Regular Expressions to create personalized goals or filters. “Why would you want to personalize your goals and filters?” you may ask. The following are a few ideas:

Using Regular Expressions can get very complex. If you have questions about using Regular Expressions or how your company could benefit from this knowledge, please contact MoreVisiblity for a free Analytics Consultation.

© 2017 MoreVisibility. All rights reserved