A simple custom field in Google Data Studio will allow you to create separate dimensions for each subfolder which works for Google Analytics, Google Search Console and really any connector where the dimension is a URL.
To do this follow these steps:
1. Edit your data connection in data studio
2. Click on add field
3. Paste in the formula – REGEXP_EXTRACT(URL, ‘^https://[^/]+/([^/]+)’)
4. Remember to give the field a unique name like “Top-level directory”
Bonus – If you want 2nd level directories paste in – REGEXP_EXTRACT(URL, ‘^https://[^/]+/[^/]+/([^/]+)’)
This is great for showing what sections of your site are winning and great for international SEO for spotting misaligned traffic if you add the Country dimension on top of.
Here’s some other great resources on segmentation in Google Data Studio:
- Google – Regular expressions in Data Studio
- Hugo Akhtari – DATA STUDIO + CASE STATEMENT: CATEGORIZE YOUR BRANDED / NON BRANDED KEYWORDS AND YOUR URLS
- Sophie Gibson – Using CASE WHEN in Google Data Studio to Supercharge Your Reporting
If you have any other use cases of segmentation or found this useful feel free to comment!