You know that feeling when you find out something that could have saved you time and your head just slouches forward? That was the moment I had when learning that RegEx is not as scary as it looks and is really very relevant, effective, and time-saving for analysts and marketers.
For those who haven’t run into Regular Expression yet, it is a digital language that allows you to specify what form of data you’d like included or excluded from your selection. This can be used when you want to only look at specific segments in Google Analytics, or want to setup a filter or goal definition.
RegEx is an extensive language that would take much longer than a blog post to explain so we’ve prepared a list of the topline characters that most benefit marketers. Those characters are:
Pipe – |
The pipe ( | ) essentially means “or”, which is an especially great help when creating filters, segments, or goals in GA. For example, if you want to create a segment that allows you to look at all your traffic from paid media without using RegEx, you can define your segment using GA like below:
However, using a RegEx ( | ) character allows you to do this in one step, increasing your efficiency like so:
This may not immediately seem like a big improvement, but when conducting analysis with large amounts of variables you will be thankful you know how to use RegEx.
*Note: if using the ( | ) character in a URL, put parenthesis around the phrases you want to interchange. For example, if you want to create a goal capturing thank you pages for a contact form that can be found on multiple pages (such as /about/contact/thank-you and /services/contact/thank-you), using parenthesis with the ( | ) will create an expression that captures both pages:
Dot Asterisk – .*
The dot asterisk combination (.*) is actually a combination of two RegEx characters that are not too helpful to marketers alone but combined they become a powerful tool. The dot (.) means match any character, which can be a letter, number, special character, or blank space. The asterisk (*) means match 0 or more of the character before it. Basically, the combined characters (.*) tell the platform there may or may not be an infinite number of characters following. This is super helpful for the analyst who is used to dealing with messy URLs in content reports. If you have ever had a similar experience, you know it’s a dream come true.
For example, if I were looking to analyze the Delphic Digital site based on the categories laid out in the navigation, I could create a segment to include all of the pages under the Services header despite their differing URLs using the RegEx: /services/.*
This will even capture URLs that have messy query parameters stuck on the end.
While there are many more useful RegEx expressions to learn, master these and you will greatly expand the scope of your analysis in GA, GTM, and any other web analytics platform you’re using.