Subdomain tracking in Google Analytics is an advanced feature. If you need further assistance with Google Analytics, please check their support page.
A subdomain comes before a domain in a URL. For example, you can create a subdomain "offer" for a landing page site, offer.the.com, and the marketing version would be www.the.com.
Using Google Analytics, you can track everything you would track for your main domain (number is visitors, views etc.) for your subdomain as well.
Be sure to capture data when visitors go from one subdomain to another: Use a single tracking ID for all of your subdomains, rather than creating a unique ID for each subdomain. Then create a view of all data of all subdomains. You can then set up a Filter to view each subdomain's data individually.
Set up Tracking
Step 1 | Signing in to Your Google Analytics Account
Go to your Google Analytics Admin panel.
Select or add a Google account to sign in.
Important: If your Analytics account is linked to a Google Ads account, data from the Google Ads account is automatically imported into any new view you create in that account.
Step 2 | Adding Your Google Analytics Tracking ID to Your Subdomains
You can find your tracking ID in the Property column of the Admin tab. Copy this ID to paste into the Google settings tab of your site. Be sure to add the same Google Analytics Tracking ID to each subdomain.
Step 1 | Retrieve your Google Analytics tracking ID:
Click the Admin icon at the bottom left of the page.
Under the Property column, click Tracking Info.
Click Tracking Code.
Copy your Tracking ID.
Step 2 | Add your Google Analytics tracking ID to your The.com account:
Go to site settings.
Go to Google, paste the code, and click Add.
Step 3 | Create Backup Views
A view is a profile of a property's data. Create a new view of your data to save as a backup before creating any other views. Save this view to save your original view and view settings, for all subdomains together. Will will allow you to save and quickly access this data when creating other views or interacting with your data.
Important: Always create a copy of your original view (with no filters) to save as a backup. Deleting views or adding filters to your original view could result in loss of data. Creating a copy of your original view makes sure you always have access to all your data.
Show me how
Select your account and property from the drop-down at the top-left.
Click Admin at the bottom-left. ￼
In the VIEW column, click +Create View.
Enter a Reporting View Name.
Tip: Use a specific and descriptive name, so you can easily tell what data is when you see the name in a list. Here, "backup of original" would be good.
Set your Reporting Time Zone.
Note: You won't see the time zone section if you link your Google Ads account to your Google Analytics account. Your Google Ads time is used by default. The time zone setting only affects how data appears in your reports and not how you collect data.
- For User ID enabled properties, click the toggle ON to create a User ID view. For a reporting view, leave the toggle set to OFF.
- Click Create View.
After you create a view, you can click Admin in the left panel and click the drop-down in the View column to select any view you have created so far. Then click View Settings to see or edit the settings for that view.
Step 4 | Add Your Root Domain to Your Referral Exclusion List
Referral traffic is the traffic that arrives on your site from another link or domain. Add your root domain (without a subdomain or www) to the referral exclusion list. Then as users move between your site's subdomains, the session will be preserved rather than creating a new session every time.
Once you add the correct code to your subdomains and you have added your root domain to the referral exclusion list, you’re already tracking subdomains.
Show me how
- Click Admin.
- Click <> Tracking Info.
- Click Referral Exclusion List.
- Enter your root domain (without www or any subdomain) e.g. mystunningsite.com or click Add Referral Exclusion.
- Click Create.
Step 5 | Create a Filter to Display Subdomains in Lists of Pages
Domains and subdomains do not show in your list of pages by default. Only the path after .com is listed, so you will not be able to tell the difference between your homepage or your subdomain's homepage.
To add your domains and subdomains to see in the stats, you need to create a filter to display the subdomains like, www., blog., mystunningwebsite.com, etc.
This filter will conflict with destination goals. You can still use this filter, but if you are using destination goals, you will need to make sure the destination is exactly the same as the page in the page list.
Filters in Google Analytics do not alter historical data. The filter that you should enter will depend on how you want to handle your historical data.
There are two different ways to do this filter.
To show the domain for all of your subdomains:
Creating a Filter
1. Click All Filters on the left panel.
2. Click Add Filter.
3. Enter Filter Name.
4. Select Custom for Filter Type.
5. Click the radio button for Advanced.
6. Check the 2 boxes next to Field A Required and Override Output Field.
7. Click Save.
To only show the domain for a specific subdomain:
To show the domain for just a specific subdomain, setup your filter, follow the steps for showing all of your subdomains, except for the Hostname field enter (subdomain.yoursite.com) instead of (.*). Use this filter if you have been using Google Analytics to track your website for a while and just added new subdomains.
Step 6 | Set Up A View For Each Subdomain (Optional)
To see your data split by subdomain, set up a view for each subdomain. This is in addition to the View that we already have that collects data on all of our subdomains.
Show me how
To add a new view:
Go to your Google Analytics Admin panel.
Select your subdomain from the drop-down at the top left.
Click Admin on the sidebar at the left.
Click Create View.
Enter the view's name under Reporting View Name.
Select your timezone under Reporting Time Zone.
To set up your new view:
Under the View column and click View Settings.
Under Website's URL, add your subdomain before your domain name, for example, blog.the.com.
(Optional) Default page (leave blank in most cases).
Enter the default page for your domain so that multiple URLs that point to the same page are treated as the same entry in your reports. For example, if example.com and example.com/index.html both open the same page, you can enter index.html in this field.
(Optional) Exclude URL Query Parameters (add a comma-separated list of any parameters you don't want in the report, e.g. sessionid or vid).
Select currency under Currency displayed as.
Click to select or unselect Bot Filtering (stats from bots & spiders).
Click to On to include visitor search query data.
Once you have created a new view, you need to apply filters to make sure each view is only collecting data on their assigned subdomain.
To apply a filter that ensures that we track only traffic for the view’s designated subdomain,
Click Admin on the side panel.
Click Add Filter under the Views column.
Applying this filter to your profile will ensure that this profile only tracks traffic for the specified subdomain. In this case, www.the.com. Remember, www is a subdomain itself. Repeat this filter for each profile that you created where you need to isolate a subdomain.