2

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:

http://sub17.domain.com

https://sub17.exh.domain.com

Any thoughts on what the filter regex should looks like?

1

I would use the regular expression on the host name:

^sub17(\.exh)?\.domain\.com$

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:

^((sub17\.exh\.domain\.com)|(sub17\.domain\.com))$

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, privacy policy and cookie policy

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