Categorise GSC Data into Site Sections in Data Studio

Need help with your enterprise or programmatic SEO strategy? Let’s chat.

I’ve finally started playing in Google Data Studio, and obviously kicking off by messing around with my Search Console data.

One of the initial things I wanted to do was categorise the landing page data into site sections, like I normally do in Google Sheets.

Thought you would need to create a reference table of all the URLs and their site sections, but then came across this post that gave some more advanced methods of categorising on the fly directly in data studio.

 

Creating a custom dimension in Google Data Studio

The first thing you need to do is create a custom dimension in Google data studio.

Click the “add a field” button in the bottom right of the data editing sidebar.

You’ll be presented with a popup which is where you can paste your site section formula.

Site Section categorisation formula

The site section formula you want to use, will be a modified version of the below formula.

case
when regexp_contains(Landing Page, “/laptops/|/other-folder-as-example/”) then “Category 1”
when regexp_contains(Landing Page, “/second-category/”) then “Category 2”
when regexp_contains(Landing Page, “/third/”) then “Category 3”
when regexp_contains(Landing Page, “/another/|/also-this/”) then “Category 4”
else “Unclassified”
end

This formula will categorise the site sections based on the text you have that is in the quotes, next to ‘Landing Page’.

You can add multiple texts for each site section by using a pipe | and that will act as an OR. So /folder-1/ OR /folder-2/ basically.

Then just change the category names to your site sections.

Extend or shorted by just adding new lines in between the ‘case’ and the ‘else’.

You will need to keep unclassified at the end, or rename it to something else, to ensure there is a fallback.

When the URL includes this and this (so includes multiple elements)

If you’d like to categorise into site sections based on requiring 2 elements, ie maybe a subdomain and a specific subfolder, then you will need the following formula instead.

case
when regexp_contains(Landing Page, “/laptops/|/other-folder-as-example/”) then “Category 1”
when regexp_contains(Landing Page, “/second-category/”) then “Category 2”
when regexp_contains(Landing Page, “/third/”) then “Category 3”
when regexp_contains(Landing Page, “/another/|/also-this/”) AND regexp_contains(Landing Page, “/this-folder/”) then “Category 4”
else “Unclassified”
end

That formula, for the last folder anyway, will ensure that either of the first 2 exist, along with ensuring that the second part also exists.

 

When URL includes something, but not something also

If you’d like to include specific folders, but ensure that a different folder didn’t also exist, then this is the formula you need.

case
when regexp_contains(Landing Page, “/laptops/|/other-folder-as-example/”) then “Category 1”
when regexp_contains(Landing Page, “/second-category/”) then “Category 2”
when regexp_contains(Landing Page, “/third/”) then “Category 3”
when regexp_contains(Landing Page, “/another/|/also-this/”) AND NOT regexp_contains(Landing Page, “/but-not-this-folder/”) then “Category 4”
else “Unclassified”
end

For the last site section, that will ensure one of the first two pieces exist, and that the last piece does not exist, to assign it to that associated site section.

 

The outcome

When you’re done, just pull the dimension in like you would normally use ‘landing page’ and it will aggregate all your data into the associated site sections.

Pretty easy was to see aggregated data, rather than just landing page level!

 

* Due to WordPress being WordPress, some of the formulas may not copy paste. You may have to replace the quotations, with new ones, as the styling may be affected.

Posts you might also be interested in

Like this article?

Share on Facebook
Share on Twitter
Share on Linkedin
Share on Pinterest

Leave a Reply

Your email address will not be published.