user5710
user5710

Reputation: 133

Google Analytics filter to include traffic based on subdomain and request URI

I'm trying to set up what I believe may be an Advanced Filter.

I want to include all traffic to the m.mydomainname.com subdomain AND also include all traffic to the page mydomainname.com/my_page.html (note that it is on my main domain, not my subdomain).

I can't just do 2 include filters, because if I include all traffic to m.mydomainname.com then that will throw out the hits to mydomainname.com/my_page.html.

Does anyone know the filters I'd need to set up to create a profile which includes all traffic to a subdomain as well as traffic to 1 specific page on my primary domain?

Thanks so much.

Upvotes: 1

Views: 2207

Answers (1)

mike
mike

Reputation: 7177

You need two custom filters:

  1. The first filter is used to combine the Hostname and URI into a Custom Field
  2. The second filter uses a regular expression, trying to match m.mydomainname.com or mydomainname.com/my_page.html against the Custom Field defined in the first filter.

For the first filter, something like:

Custom filter
Advanced
Field A -> Extract A: Hostname, (.*)
Field B -> Extract B: Request URI, (.*)
Output To -> Constructor: Custom Field 1, $A1$B1

For the second filter, something like:

Custom filter
Include
Filter Field: Custom Field 1
Filter Pattern: m\.mydomainname\.com|mydomainname\.com/my_page\.html

The second filter includes all traffic or m.mydomainname.com OR the single page mydomainname.com/mypage.html


When working with filters, it's a "best practice" to use two profiles:

  • one profile with no filters, that collects all data
  • one profile using the filter(s).

Upvotes: 2

Related Questions