I have a site that has cross-domain tracking setup on it for 4 domains. 2 of those are subdomains from one domain. I have been trying to setup a filter for a view that only includes traffic from those two subdomains but not luck. subdomain structure is as follows:



Any thoughts on what the filter regex should looks like?

1 Answer 1


I would use the regular expression on the host name:


The . need to be escaped because otherwise they match any character. The parenthesis around \.exh with the question mark make it optional to allow either version of your host name to be matched. The ^ at the beginning and $ at the end ensure that it is an exact match. The help indicates that Google uses regular expressions in "find" mode.

An alternate regular expression that should do the same thing would be:


In this case it has an explicit or with | right in the middle and uses parenthesis to ensure order of operations is correct. This version is quite a bit longer, but might be easier to understand. It would also be easier to add additional host names to this version.

You should set it up like this:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.