The most widely applied tool for measuring and evaluating a website is Google Analytics. Google Analytics has out-of-the box functionality that helps to know the performance of the website in search visibility. Regular Expressions are the most happening source in Google Analytics. A set of characters that specify a pattern is referred as regular expression. It usually is derived from the expression of the term that uses grammars and formal languages.

Google Analytics gives support through regular expressions for creating more influential implementations for user. Regular Expressions are the special characters that relatively match or confine portions of a field, as well as the rules that direct all characters. Regular Expressions are used to create filters, create one goal and fine-tune expressions for matching data and execute an action when the right match is achieved.

Regular expressions are also called as regex used in Google Analytics to find URLs (or almost anything else) that shapes a definite description.

Common Regular Expression Metacharacters:

Metacharacter Description
. Matches any single character.
[   ] Matches a single character that is contained within the square brackets. Referred to as a class.
[^   ] Matches a single character that is not contained within the square brackets. Referred to as a class.
^ Matches the beginning of the string. This is referred to as an anchor.
$ Matches the end of the string. This is referred to as an anchor.
* Matches zero or more of the previous item.
? Matches zero or one of the previous item.
+ Matches one or more of the previous item.
| The OR operator. Matches either the expression before or the expression after the operator.
\ The escape character. Allows you to use one of the metacharacters for your match.
(   ) Groups characters into substrings.

The Best Way to Learn Regex

Here you are going to learn how to customize a report in Google Analytics.

For Example:

We will use a Pipe symbol [ “|” ] to generate a Regular Expression (RE) to get a customized report.

To begin with, sign in to your Google Analytics account, select your website profile and navigate to Standard reporting as shown in the image below:

  • You can now navigate to Traffic Sources > Sources > Direct & select “Advanced” filter option as shown in the image below:

  • The screens will expand like below on clicking “Advanced”:

  • Select “Dimension tab” to change the dimension.
  • From the list of dropdown menu, select “Matching RegExp.”
  • For the number of different landing pages to be displayed, write Your RegEx as “(Search-engine-optimization.php|contact-us.php)”.
  • Google Analytics will now display all the landing pages with those words in the URL.