Goal: To set up a hostname filter in Google Analytics that will add your page’s subdomain information to your reports.
Ideal Outcome: You should be able to easily and accurately analyze your traffic reports and immediately distinguish the traffic among your subdomains.
Prerequisites or requirements: You need to have Google Analytics running on your website and all your subdomains, if you haven’t added it yet you can do so by following
The specific steps on this SOP apply only to Universal Google Analytics (not Google Analytics 4). If you followed other ClickMinded SOPs to create your Google Analytics account or if you set up Google Analytics before October 2020 you most likely have a Universal Analytics property.
Why this is important: If your website has multiple subdomains, Google Analytics will aggregate data that has the same page path. Understanding which sessions belong to which subdomains will require you to go through a few extra steps every time you’re analyzing results. This filter adds the subdomain information straight to your reports.
Where this is done: In your Google Analytics account.
When this is done: Only once per view.
Who does this: The person responsible for Analytics.
- SOP Update: Google Analytics 4
💡 Note: Google has released a new version of Google Analytics in October 2020, this new version can be set as a property alongside standard version “Universal Analytics”. The “Universal Analytics” properties will likely be supported by Google for years to come. Currently, all ClickMinded SOPs support Universal Analytics exclusively.
To make sure you can follow this step-by-step SOP make sure you have selected the Universal Analytics property once your Google Analytics account has been created.
- On the top left corner click on the Account Dropdown and select a view within your Universal Analytics property (Not the GA4 property):
**Note: You can identify your Universal Analytics property by noticing the ‘UA-’ prefix in the Property ID below its name:
- Adding a Hostname Filter
- Go to your Google Analytics Admin panel by clicking here.
- If you have multiple Google Analytics accounts make sure you have selected the correct account, property, and view:
- Remember: Filters are destructive, they permanently modify the incoming hits. That’s why you should make sure you are not doing these changes in your main and only view. For this SOP we are going to be using the “Staging View”, If you haven't set up views on your account, check out our Google Analytics setup SOP.
**Note: Make sure you select the Google Analytics - Universal Analytics property (Property ID starts with UA-)
- Click on “Filters”:
- Click on “Add Filter”:
- Name your filter → Select “Filter Type: Custom”
- In the first dropdown select “Hostname”, select “Request URL” for the second, and select “Request URL” once again for the last one.
- Select “Advanced” and fill in these settings:
- Field A -> Extract A: (.*)
- Field B -> Extract B: (.*)
- Output To -> Constructor: $A1$B1
- Your settings should now look like the picture bellow, if that is the case you’re ready to hit “Save”:
- That’s it! You should now be taken to your Filter table and your filter should now be active:
- Important: Possible impact of this change in your data
If you already have this Google Analytics property for some time and it already contains important historical data you should be aware that this change might impact:
- Your “Destination” Goals if they are using the “Equals to” or the “Begins with” match-type.
- Note: Some RegEx match-type Goals might be affected by this change as well. If you’re using a RegEx destination goal you might want to ask the person that implemented those goals or a developer beforehand.
- Note 2: To update your Goals so that they keep working after this change you should now update the “Destination” field so it now includes your subdomain as well. If you are not sure on how to find your goals, or how to set them up you can refer to SOP 021 and simply update the existing goals instead of creating new ones:
- Any “Dashboard”, “Custom Report”, or “Custom Alert” where the “Page” dimension is being used as a filter.
- Any other customization you might have applied to Google Analytics or any third-party tool that uses the “Page” dimension.
- It will be harder to analyze time-periods that include the date of this change since Google Analytics will be treating all the pages as different ones from the day of this change onwards.
If that is the case you might prefer to keep your current setup, and apply this settings to an entirely new view, this way your data will not be affected by this change. For instructions on how set up new views you can check SOP 009.
- Checking If your filter is working as intended
- Open your website using Chrome.
- Click on the Google Tag Assistant Chrome extension and click “Record”:
- Refresh your page.
- Click again on the Google Tag Assistant Chrome extension and click “Stop Recording” and then click “Show Full Report”:
❯
- Select “Google Analytics Report”:
- Select the view that you want to test and click “Ok”:
**Note: Make sure you select the Google Analytics - Universal Analytics property (Property ID starts with UA-)
- Scroll down in the report until you find the “Flow” section → Click “Page Load 1” → Click “Hit 1”. You should see the “Mutation” subsection displaying the transformation that occurred in your reported hit:
- That’s it! If everything looks ok you should start seeing the new data in your reports in the next 24h.
**Remember
: This change will only affect data going forward. Your past data will still be reported as it was recorded back then.