4.9K members online now
4.9K members online now
Ask questions about filter set-up and issues with using filters in Google Analytics reports
Guide Me

Filter for subdomain AND different subdirectory

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭


Wondering if anyone can help me with this.


One of my clients is using a subdomain and a subdirectory not on that subdomain for a specific ongoing 'sub-program' they're doing.


e.g. its homepage is on and the rest of the content is They want to filter out this data together. Is it possible to create a view filter using custom field 1 and regular expressions to filter these out at the same time?


e.g. to include only:



Or are there any other ways to see data for just the subprogram?



Marked as Best Answer.
Accepted by topic author Rianne O
November 2016

Filter for subdomain AND different subdirectory

Explorer ✭ ✭ ☆
# 2
Explorer ✭ ✭ ☆

Hi @Rianne O


Yes, it's possible with a couple for filters. Create a new view, and create a new filter to first rewrite all Request URIs to include the hostname.


First, append the hostname to the Request URI:

1. Create a custom filter of the type Advanced

2. Set the first extract field to Hostname and the second to Request URI

3. Enter (.*) in both fields

4. In the Output field, set it to Request URI and the value to $A1$B1


Then create another custom filter of the type Include:

1. Set the Filter field to Request URI

2. Enter the pattern: ^(subprogram\.website\.org|website\.org/program/subprogram/)

(which is just as you suggested yourself)


You could accomplish something similar using Advanced Segments - but they would include traffic on other pages as well if those pages are visited during the same sessions as the target pages.


Note! I haven't tested the above filters - you should do that :-)

Filter for subdomain AND different subdirectory

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭

Hi @Phillip S,


Thank you so much for your help!

I implemented it with: 


because the ^ excluded some of the pages that we needed as well and the '/subprogram' is also a page we need to track.


Now it looks like it will include everything we need according to the filter verification tool, though in real time it is not reflected yet. I'll check again tomorrow and will let you know if it is working.

Re: Filter for subdomain AND different subdirectory

Visitor ✭ ✭ ✭
# 4
Visitor ✭ ✭ ✭

Hi @Phillip S

In this situation, if we compare the bounce rate of the page /program/subprogram in Analytics from the original (all data) view and the one in the filtered view, the bounce rate for the filtered view is higher. Is this because if a user leaves any pages within the filter but stays on the website, it would be a bounce in the filtered view but not in the all data view?

Thanks for your help!

Filter for subdomain AND different subdirectory

Visitor ✭ ✭ ✭
# 5
Visitor ✭ ✭ ✭

Hi @Phillip S,


I am created what ever u suggested above for host name filter for my separate view for Subdomain & I am not create another filter Request URL any problem for that one??


I am not tracking the visitors of my sub domains ...


And I added GTM also cookie domain in Tag??


please help on this... TQ