How to Set Up GA4 Reporting for Website Subfolders?

Question from Reddit user:

I have been trying to research this but have not found any clear solution for creating filters for subfolders.

I work for a university where we have our domain (xxxx.edu) but all of our departments have their own website in a subfolder (xxxx.edu/math, xxxx.edu/studentaffairs, etc.).

In UA when working with a department I would create a view and filter the data only to show data for URLs that included the subfolder (ex.

/studentaffairs/).

I would also use this view when syncing our GA to other tools like SEMrush to view only that website’s data.

But in GA4 I have been struggling to find any way to filter our data down.

I could create a dashboard in Looker Studio and filter it there, but is there a good way to do this directly in GA4?

Answer from Nabil:

The short answer is:

How to set up GA4 reporting for website subfolders?

You can’t replicate the old Universal Analytics “View Filter” for subfolders directly in a GA4 Property because GA4 is designed around a single, unfiltered stream of data, meaning there is no way to permanently filter data at the property level for all users based on a URL subfolder like /studentaffairs/.

The most effective solution within the GA4 interface itself is to use Audiences or Explorations.

For department-specific reporting, you should create a custom Audience that includes users who have viewed pages whose Page path or page_location contains the subfolder string, and then use that audience in your standard reports or Explorations.

For syncing with other tools, you’ll rely on the Google Analytics Data API to extract and filter the data before connecting to tools like SEMrush.

The long answer is:

Your challenge is a common pain point for users transitioning from Universal Analytics, where Views and View Filters were perfect for segmenting data by subfolder.

In GA4, the concept of a permanent, filterable View has been replaced by a single Data Stream, which is why you can’t find the old setting.

The best approach within GA4 for your reporting needs is a two-step process.

First, for ongoing analysis, you should create an Audience for each department.

For example, for the Student Affairs department, you’d create an audience where the criterion is based on the page_view event, and you add a condition where the Page path dimension (or the page_location dimension if using an event parameter) contains /studentaffairs/.

Once created, you can apply this audience as a Comparison in any standard report or as a Segment in any Exploration report to focus your analysis solely on that department’s traffic.

Second, for syncing with external tools like SEMrush, you cannot use a simple audience or segment.

You must use the Google Analytics Data API to programmatically pull data, applying the necessary filter for the subfolder in your API request itself.

This is where an advanced data architecture becomes an excellent solution.

By utilizing Google Tag Manager and a server-side environment like Stape or Google Cloud Platform, you can automatically enrich all events with a custom department_name parameter based on the URL subfolder before the data is even sent to GA4.

This custom dimension could then be easily pulled via the Google Analytics Data API alongside your metrics.

For visualization and easy sharing, you can then connect this API data pull to Looker Studio via its connector or the Looker Studio API.

This final setup gives you a dedicated dashboard for each department that is automatically filtered and scalable, making it easy to share clean, subfolder-specific data with your departments and ensuring that the data you export to tools like SEMrush is accurately filtered before it leaves your own reporting environment.

About The Author