SEO

How to Utilize RegEx to Track Your SEO Efforts

What are Regular Expressions (RegEx) and RegEx Strings?

A Regular Expression, commonly referred to as RegEx, is a formula that uses unique operators, such as “|” or “$”, to isolate a certain subset of data from a larger dataset.

So that begs to question, what is a RegEx string? Let’s look at an example.

Say you’re working on the Seer Interactive website and you provided metadata and on-page recommendations for 5 pages that just got implemented on the site:

  • https://www.seerinteractive.com/
  • https://www.seerinteractive.com/blog/
  • https://www.seerinteractive.com/services/seo/
  • https://www.seerinteractive.com/services/ppc/
  • https://www.seerinteractive.com/services/paid-social/

Your next step is to log in to Google Analytics and look at the performance of your new changes, but as you may have come across before, your Google Analytics view has A LOT of URLs. Seer, for example, has upwards of ~1,300 unique URLs.

pasted image 0 52

So how can we isolate the 5 URLs that we optimized to quickly check the performance of our recommendations?

Enter the RegEx string. In its final version, it would look like this:

^www.seerinteractive.com/$|^www.seerinteractive.com/blog/$|^www.seerinteractive.com/services/seo/$|^www.seer

interactive.com/services/ppc/$|^www.seerinteractive.com/services/paid-social/$

Below we’ll talk about the underlying operators in this RegEx string and how they impact what we will eventually see within Google Analytics or your desired platform.

Common RegEx Operators You’ll Need for SEO Reporting

RegEx can take many forms depending on the platform you’re using (think Google Analytics, Google Data Studio, Screaming Frog, etc). For the purposes of SEO reporting, here are three main operators you’re going to need to have on hand.

  1. ^ or Caret – tells Google Analytics that you’re starting the RegEx string
    1. In our example, you can see how our RegEx string starts with the ^ and each subsequent URL that we’ve optimized starts with a ^ (bolded below)

^www.seerinteractive.com/$|^www.seerinteractive.com/blog/$|^www.seerinteractive.com/services/seo/$|^www.seer

interactive.com/services/ppc/$|^www.seerinteractive.com/services/paid-social/$

  1. $ or Dollar Sign – tells Google Analytics that for a given URL, we don’t want to see any other URL that may live on that subfolder and nothing should come after the $
    1. In our example, you can see how our RegEx string has a $ after every URL (bolded below)

^www.seerinteractive.com/$|^www.seerinteractive.com/blog/$|^www.seerinteractive.com/services/seo/$|^www.seer

interactive.com/services/ppc/$|^www.seerinteractive.com/services/paid-social/$

  1. Why does this matter? Say, for instance, we didn’t include a $ after the URL www.seerinteractive.com/blog/ within our string (underlined below). This means that we’re telling Google Analytics to pull every single URL on the seer interactive website that is under the /blog/ subfolder instead of just isolating the one URL that we want to isolate from the rest of the group.

^www.seerinteractive.com/$|^www.seerinteractive.com/blog/|^www.seerinteractive.com/services/seo/$|^www.seer

interactive.com/services/ppc/$|^www.seerinteractive.com/services/paid-social/$

  1. | or Pike – tells Google Analytics or Google Data Studio that we’d like to isolate and only look at URL A OR URL B OR URL C OR etc…
    1. In theory, you can read our RegEx string to yourself like so:

^www.seerinteractive.com/$ OR ^www.seerinteractive.com/blog/$ OR ^www.seerinteractive.com/services/seo/$ OR ^www.seerinteractive.com/services/ppc/$ OR ^www.seerinteractive.com/services/paid-social/$

How to Implement RegEx for SEO Initiatives

Now that we’ve created our RegEx string, we can navigate into Google Analytics and go through the following steps:

  1. Navigate to a Landing Page View of your choice. For example:
    1. Acquisition > Channels > Organic Search

pasted image 0 57

OR

  1. Behavior > Site Content > Landing Pages

pasted image 0 50

  1. Select Advanced
  2. Within the field that opens up, select the drop-down option and select “Matching RegExp”
  3. Paste in your RegEx String (a completed example is pictured below)
  4. Click “Apply”

pasted image 0 55

The final view within GA will now filter for only the URLs within your string and look something like this:

pasted image 0 53

Now remember; the point of using RegEx is to track our SEO performance for pages that we’ve recently optimized. Don’t forget to adjust your date range to reflect the date on which your changes went live!

Example: If we implemented changes to those 5 Seer Landing pages on February 14th, 2020 then we should be looking at a time range that reflects an equal number of days before and after February 14th, 2020 by using the previous period function within the date range filter in GA.

pasted image 0 56

The Importance of RegEx

In summary, RegEx and RegEx strings are a powerful and efficient way to track performance of SEO recommendations from within Google Analytics. By isolating a subset of URLs from a larger set, we can properly report on the value we’re driving for our clients or business.

For more information on how to implement RegEx, check out our post on using Regular Expressions to Create Filters in GA.

Sign up for our newsletter for more posts like this – delivered straight to your inbox!