Tracking Subdomains with Google Analytics is not as complicated as it may seem. But it’s important to get the settings right to make sure that you are tracking Sessions and Users the proper way. Read more here to find out how to track or exclude Subdomains in Google Analytics Views the smart way!
Requirements to track Subdomains with Google AnalyticsFirst of all, you will need to set up cross domain tracking in Google Analytics or Google Tag Manager. (Use the links to find a tutorial on that on my site). But why will you need cross-domain tracking? Well, Google Analytics is set to track only the traffic arriving at one domain where the Analytics tag is included. You could say “let’s include the Analytics tag on more than just one domain” and you are almost right. This is part one of the deal. The problem that you’d have is that a user who arrives at something.domain.tld and moves forward to www.domain.tld would trigger two different sessions. But this is not what you will want to see in your cross-domain tracking setup. You’d like to see only one session for this user, right? So here is how to do it: Cross Domain Tracking in Google Analytics or Cross Domain Tracking in Google Tag Manager. The way to accomplish this task is not to work with referral exclusion lists but to work with filters in your Google Analytics account. Besides the available standard filters, you are able to set individual filters that will help you to track only the traffic that arrives at a Subdomain. Here is how to do it:
Visit your Admin page for your Google Analytics PropertyYou will find a gear-wheel symbol in the lower left corner in your Google Analytics Account which leads to the admin page. Klick on it. You will now be forwarded to the Setup view of your Analytics account. The part we are now taking a closer look at is the outer right settings column, which is responsible for all view related settings (marked red in the following screenshot). Please find the “Filter” subsection and click on it.
Setting a Filter to only track SubdomainsAfter you clicked on filters you will be forwarded to a different part of the settings page where you are able to add filters. Click on the button which says “+ Add Filter”. Now you can give your filter a custom name, activate the include radio button and more options will show up. Set the filter “Field” to Request URl and the filter “Pattern” to something\.domain\.tld You are set and can confirm the setting by scrolling down and click on save. After the page reloaded, the filter according to the name you assigned to it should now appear in the list. The settings should now look like this: Setup an Analytics View to exclude Subdomain traffic First, you need to visit your Analytics Settings Page (see above for details). From there you should also go to the Filters sub settings below the view settings column. From there the steps to exclude the subdomain from one view are as follows:
- Set filter type to Custom Filter
- Activate the radio button named Exclude
- Set filter field to Request URL
- Set filter pattern to something\.domain\.tld
- Click on Save after scrolling to the bottom of the page