Google Analytics Advanced Regular Expressions RegEx

How to Use RegEx for Advanced Google Analytics for Quick Decision Making Process

Google Analytics offers plenty of useful metrics to the data analyst to make a fast & reliable decision making on their Website/App/PoS and many other digitally connected media. Google Analytics has two sections, first is Google Analytics for Beginners and rest is Advanced Google Analytics. Time is precious. Strategic decision making needs to be done in real time, whilst the same can’t be achieved by beginners. Hence, it’s time to move on to Advanced Google Analytics for Easy & Quick decision-making process. RegEx for Google Analytics is one powerful tool in advanced analytics segment. Let us learn how to use regular expression in Google Analytics to make a fast decision.

What is Regular Expressions or Regex in Google Analytics?

Regular Expressions are special characters that are used to find a specific pattern in a list. It can also be used as Wildcards. In terms of Google Analytics, RegEx is used to find URLs that match the description.

You can use Regex in google analytics to

  • Create Advanced Filters
  • Create Unique Goal, and
  • Fine tune your Funnels

Fundamentals of RegEx for Google Analytics:

 

Google Analytics Advanced Regular Expressions RegEx
Google Analytics Advanced Regular Expressions RegEx

Let me start with the basics of Regex in Google Analytics. There are 13 basic regular expression characters available to use in Google Analytics. Those characters are the key aspects that make your analysis easy and fast.

Regular Expression used in Google Analytics is as follows

Characters Expressions
Asterisk ( * )
Backslash ( \ )
Caret ( ^ )
Curly Brackets ( {} )
Dashes ( – )
Dollar Sign ( $ )
Dot ( . )
Dot-Asterisk ( .* )
Parenthesis ( ( ) )
Pipe ( | )
Plus Sign ( + )
Question Mark ( ? )
Square Bracket ( [] )

 

 

 

 

 

 

Note: RegEx becomes powerful when it is used with two or more combinations.

Google Analytics Regular Expressions with Examples:

Let start with the simple examples of how to use regular expressions in Google analytics for quick decision makings.

Pipe Symbol RegEx ( | )

Pipe symbol is the simple RegEx to use in Google analytics. It performs “OR” operation.

In this example, I used pipe RegEx to match the /accessories and /bags URL.

Pipe Symbol Google Analytics Regex
Pipe Symbol Google Analytics Regex

Note: Interestingly, some of the pages which consist of these subdirectories will also get matched and listed here. Let me explain you later about how to use RegEx more precise for decision making.

Dot Symbol RegEx ( . )

The Dot RegEx matches any character. It can also be used as Wildcard RegEx.

In this example, I used “.ies” and it would match “accessories”, “policies”, “activities” and not “ies” alone.

Dot Symbol Google Analytics Regex
Dot Symbol Google Analytics Regex

Note: Dot RegEx symbol equals ONE character.

Asterisk Symbol RegEx ( * )

The Asterisk RegEx matches zero or more of the previous characters in a string.

I used to “s*rt” as a regex and it will match “shirt”, “short”, “start” and so on.

Asterisk Regex Google Analytics Example
Asterisk Regex Google Analytics Example

Dot Asterisk RegEx ( .* )

The dot-asterisk is another powerful RegEx combination in Google analytics. This RegEx matches zero or more random characters. In other words, it simply matches everything that comes underneath.

For example, I am running a kitchen cabinet e-commerce service across United Arab Emirates (UAE). I want to figure out which emirates yield good traffic to my business. The dot-asterisk helps me in analyzing the same.

I applied “/uae/.*/kitchen-cabinets” and the output is amazing.

Dot Asterisk Regex Google Analytics Example
Dot Asterisk Regex Google Analytics Example

It returns all the “kitchen cabinet” pages across the emirates within a few seconds.

Backlash Symbol RegEx  ( \ )

The backlash symbol is one of the highly used RegEx symbols for analyzing. The power of this \ symbol is it turns all the special characters into normal or plain characters.

Backlash Google Analytics Regex Example
Backlash Google Analytics Regex Example

I prefer this backlash RegEx for IP Filter Creation in Google Analytics.

Caret Symbol RegEx ( ^ )

The Caret ^ RegEx represents something that begins with.

I applied “^/store” which helps me in finding all the pages that begin with “store” on the website.

Caret Regex Example in Google Analytics
Caret Regex Example in Google Analytics

Note: The Caret RegEx must be used precisely. The caret mandates that the matching character must be at the beginning of the target string. If not configured properly, it will never match and brings 0 results.

Dollar Symbol RegEx ( $ )

Caret and Dollar are like Tom & Jerry, hope you guessed it right! As you know caret matches the character that begins with, the dollar is vice versa.

Yes, the $ matches the string that ends with.

I applied “wear$” and it brings the pages that strictly ends with the “wear” and not “wears” or any other.

Dollar Symbol Regex Example
Dollar Symbol Regex Example

Question Mark RegEx ( ? )

I prefer this question mark regex mostly during the hunt for the misspellings in the site. The question mark symbol means the last character is optional.

Example:

Say you are running a PPC campaign for Apple Inc. Now, you need to find out the impressions your campaign made for “Steve Job”. There comes the help of question mark RegEx.

Question Mark Regex Example
Question Mark Regex Example

If you apply “Steve Jobs?” in the filter section, you will get the queries that yields you impression i.e. both “Steve Job” and “Steve Jobs” as well.

Parenthesis RegEx ( )

If you love mathematics, then parenthesis will be your lovable RegEx for Google Analytics. This is because the parenthesis works same as it works in mathematics.

Example: /apparel/(mens|womens) regex helps me to find all the apparel URLs that have either mens or womens

Parenthesis Google Analytics Regex
Parenthesis Google Analytics Regex

Square Brackets ( [] )

This Square Bracket regex helps in making a simple list.

For example: [bcd]. It is combined with other characters a[bcd]e will give results like abe, ace, ade and not “abcde”.

Dashes ( )

This dash symbol is one of the top advanced regex in Google analytics. It helps in creating a most advanced list of items.

  • Use [a-z] to match all lower-case letters
  • Use [A-Z] to match all upper-case letters
  • Use [0-9] to match all numbers
  • Use [a-zA-Z0-9] to match all lower-case and upper-case letters and numbers

If you are analyzing an eCommerce website, then, Dash Regex will be the very handy syntax.

Example: You have a shoe product of 4 different sizes from the same brand. You named it as,

  • Reebok Special 2018-6
  • Reebok Special 2018-7
  • Reebok Special 2018-8
  • Reebok Special 2018-9

Dash Regex syntax of “Reebok Special 2018-[6|7|8|9]” gives you the power of monitoring all the four products effectively.

Note: The Dash & Square bracket combination makes the regex more powerful.

Plus Sign RegEx ( + )

The plus symbol regex matches one or more of the previous characters.

For Example: Money+ matches all the following

  • Money
  • Moneyy
  • Moneyyy
  • Moneyyyy and so on

Curly Brackets RegEx ( {} )

For this curly bracket regex, you must keep your analytical & mathematical brain sharp! The curly bracket regex has a certain complex in understanding it.

  • {1,3} – represents, repeat the last item at least 1 time and not more than 3 times.
  • {2} – represents, repeat the last item twice (2 times).

Let me explain you the curly bracket regex with an IP Filter.

For example: Your office uses an IP range of 128.125.168.0 to 128.125.168.75, and your duty is to filter those IP ranges in your Analytics report.

Use this curly bracket regex: ^128\.125\.168\.[0-9]{1,2}

Note: You can also use this curly bracket regex to filter ZIP codes.

Advanced Tips for Using RegEx in Google Analytics:

  • Shouldn’t use | symbol either at the beginning or end of the expression, as it basically performs OR operation.
  • Try to make all the possible combinations in a single RegEx to keep it simple.
  • Don’t ever try spaces in URLs.
  • RegEx isn’t case sensitive (you can make them case sensitive as well)
  • RegEx in Google Analytics has a limit of 256 characters. Make sure your regex doesn’t exceed the limit.

Conclusion:

A regular expression is a valuable tool for the digital marketers. You can play with RegEx by creating unique filters, fine goals, by using the power matching techniques for easy decision making. You can solve problems and achieve reliable results as faster as possible with RegEx for Google Analytics. If you are a beginner, why don’t you try testing & practice the above-mentioned Google Analytics Regular Expressions guide to master it? The more your master Google Analytics RegEx, the faster, efficient and accurate your report will be.

If you want to share any creative powerful Regex in Google Analytics, don’t hesitate to do so in our comment section.

Make the world knows you find one good article on RegEx for Advanced Analytics by sharing it on social media.

Leave a Comment

Your email address will not be published.

Scroll to Top