In our user forums, we often get asked about ways to handle subdomain tracking in Google Analytics. Subdomain tracking is needed whenever you want to track multiple domains like this:

  • www.example.com
  • blog.example.com
  • cats.example.com

in the same Google Analytics profile.

Subdomain Tracking Video

Steps:

  1. Install GA code. Default UA code, all subdomains.
  2. Create views, filters and exclusions.
  3. Test
  4. Run a celebration lap!

Notes:

When setting up the ‘Show subdomain filter’, here’s what you need:

Filter Type: Custom, Advanced

Field A -> Extract A

HOSTNAME  —->  (.*)

Field B -> Extract B:

REQUEST URI  —-> (.*)

Output To -> Constructor

REQUEST URI  —->  $A1$B1

Click SAVE.

Lastly, test using Google Analytics Real Time reports which browsing the site in another window to see the hostname populate.