Mobile app version of vmapp.org
Login or Join
Gonzalez347

: Google Analytics include traffic only from two sub domains filter 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

@Gonzalez347

Posted in: #GoogleAnalytics #RegularExpression

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:
sub17.domain.com sub17.exh.domain.com
Any thoughts on what the filter regex should looks like?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Gonzalez347

1 Comments

Sorted by latest first Latest Oldest Best

 

@Megan663

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:

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme