Universal Analytics allows tracking of two of more subdomains within a single property without any additional configuration. For example, if you have website.com, blog.website.com, and info.website.com and you would like to track them all within one Google Analytics account, under the same property, you can track all of these subdomains using the same Universal Analytics code as your main domain. This article is going to provide you with step-by-step instruction on how to implement this.
Tracking two or more subdomains within a single property
This is supported by the default tracking code in Universal Analytics; you can do this by placing the same Universal Analytics tracking code on all of your web pages under your main and subdomains. You can also implement the tracking code through Google Tag Manager. I highly recommend using Google Tag Manager, as it allows you to implement tracking of different activities on your website without involving your developers. Simply implement the Google Tag Manager code on your site and subdomain sites the same way you would to Google Analytics. See more detail on how to implement here: How to Setup Google Analytics Using Google Tag Manager 2.0
Add hostname plus request URI
To distinguish between request URIs on the different domains, you need to apply an advanced filter to your working view(s) that prepends the hostname (subdomains or domains) to the request URI.
- /digital-analytics will become blog.siteber.com/digital-analytics
- /google-tracking will become siteber.com/google-tracking
This way, when you look at the reports in Google Analytics, you’d be able to distinguish between different subdomains and domain. Here are the steps to apply the advanced filter to add the hostname to the request URI.
- Go to Admin section of your Google Analytics account, under view, select filters.
- Create a New Filter using the following configuration:
- Filter Name: Show Full Domain
- Filter Type: Custom, Advanced
- Field A-> Extract A: Hostname: (.*)
- Field B-> Extract B: (.*)
- Output to-> Constructor: Request URI: $A1$B1
- Check Field A Required
- Check Override Output Field
Filter by hostname
To easily view activity on a single domain or subdomain that you’re tracking with other domains or subdomains in a single property, you can create additional views that are filtered to include only hostname.
After you have added hostname plus request URI, you should be able to easily create different views for your different subdomains and your main domain.
To create different views, click on View, and create new view. Each property can have up to 25 views. Normally you’d want to have at least three different views for each property you are tracking.
- Master (Working)
Go through the process of creating new views, and then go to Filters again.
- Click on +New Filter, and pick Apply existing Filter, you should be able to see all the filters you have created (go to Add hostname plus request URI if you haven’t created a Full Domain filter already). Add the full domain filter and click save.
- Click on +New Filter, name your new filter (for example, Blog.siteber.com Traffic Only).
- Filter Type: Predefined
- Include only, traffic to the hostname, that begin with
- Hostname: blog.siteber.com
You can verify your filter.
Make sure the filter Show Full Domain is before the blog.siteber.com traffic only filter as it filters based on the full domain URL.
By following the steps above, you can create different views for each of your properties.
Let me know if you have any problem configuring subdomain tracking below in the comment section.