How to Track Subdomain in Google Analytics
Trying to analyze traffic across your main website and various subdomains - like blog.yourdomain.com or shop.yourdomain.com - can feel like you're tracking two completely different businesses. By default, Google Analytics treats them separately, breaking the customer journey right in the middle. This article will show you exactly how to set up subdomain tracking in Google Analytics 4 so you can see the complete picture of how users interact with your entire online presence in a single, unified view.
What Is Subdomain Tracking and Why Does It Matter?
Imagine a potential customer lands on a blog post at blog.yourdomain.com from a Google search. After reading, they click a "View Pricing" button that takes them to yourdomain.com/pricing and they sign up. Without proper subdomain tracking, GA4 sees this as two disconnected events:
- Session 1: A new user from Organic Search lands on your blog. The session ends when they click the pricing link.
- Session 2: A new session begins on your main site, with the source listed as "Referral" from
blog.yourdomain.com.
This broken journey completely messes up your data. The original source (Organic Search) doesn't get credit for the conversion, your session counts are artificially inflated, and your own blog is listed as a top "referral" source, which is not helpful.
Setting up subdomain tracking (often called cross-domain tracking in GA) fixes this mess and offers huge benefits:
- A Complete Customer Journey: You can trace a user's entire path, from an ad click that lands them on a promotional subdomain to a purchase on your main eCommerce site. This helps you understand the true performance of your content and user funnels.
- Accurate Attribution: You'll correctly attribute conversions to the original traffic source. You'll know it was the Facebook ad or the initial Google search that brought the user to your digital doorstep, even if they navigated across multiple subdomains before converting.
- Cleaner Analytics Data: Say goodbye to skewed metrics. Your user and session counts become more accurate, and you stop seeing your own subdomains polluting your referral traffic reports.
- Simplified Reporting: You can analyze your entire web presence within a single GA4 property, rather than navigating between separate properties for your blog, app, and main site.
The Good News: GA4 Makes Subdomain Tracking Easy
If you have any PTSD from setting this up in Universal Analytics (UA), you can relax. GA4 simplifies this process immensely. In UA, you had to manually create filters, configure referral exclusion lists, and sometimes even modify the tracking code itself. It was fragile and easy to get wrong.
Google Analytics 4 was built with the modern, multi-platform user journey in mind. Its streamlined approach makes cross-subdomain tracking virtually automatic, as long as you follow a couple of simple but crucial configuration steps. You just need to tell GA4 which domains are part of the same business entity, and it handles the rest.
How to Set Up Subdomain Tracking in GA4: A Step-by-Step Guide
Setting this up involves two main phases: ensuring the same GA4 tag is on every page of your domains and subdomains, and then configuring the domain settings in your admin panel. Let's walk through it.
Prerequisite: Use the Same GA4 Tag and Measurement ID Everywhere
For GA4 to successfully track users across subdomains, all pages must use the exact same GA4 tracking tag. This means the Measurement ID (which looks like G-XXXXXXXXXX) must be identical across yourdomain.com, blog.yourdomain.com, and any other subdomains you want to track.
You can verify this quickly:
- Navigate to your main website (e.g.,
yourdomain.com). - Right-click on the page and select "View Page Source".
- Use
Ctrl+F(orCmd+Fon Mac) to search for "G-". Note the full measurement ID (G-XXXXXXXXXX). - Now, open your subdomain (e.g.,
blog.yourdomain.com) in another tab and repeat the process.
If the Measurement IDs match, you're good to go. If they are different, you're using two different GA4 data streams, and the tracking will not work. You must consolidate and use a single measurement ID for all parts of your site. Most content management systems (like WordPress) or website builders have a designated field in their settings where you can update this GA4 ID.
Step 1: Go to Your Admin Settings
Once you've confirmed you're using a single GA4 tag, log in to your Google Analytics account. Click the Admin gear icon in the bottom-left corner of the screen.
Step 2: Navigate to Data Streams
Make sure you have the correct Account and Property selected. In the Property column, click on Data Streams. This will show you the list of data streams associated with this property.
Step 3: Configure Your Tag Settings
Click on the web data stream for your website. This will open the detailed view for that stream. At the bottom, under the Google tag heading, click Configure tag settings.
Step 4: Configure Your Domains
You'll now see the Google tag settings screen. In the Settings section, click on Configure your domains.
Step 5: Add All Your Relevant Domains
This is the most critical step. Here, you'll tell GA4 which domains should be treated as part of the same user journey.
You need to create a condition that includes your root domain. This will automatically cover all of its subdomains.
- Leave the Match type as contains.
- In the Domain field, enter your root domain (e.g.,
yourdomain.com). - Click Add condition.
By entering yourdomain.com here, you're instructing GA4 that any URL containing this string — including www.yourdomain.com, blog.yourdomain.com, and shop.yourdomain.com — is part of the same website entity.
Finally, click Save in the top right corner. That's it! GA4 will now automatically handle passing user and session information across these domains.
A Quick Note on the Referral Exclusion List
In Universal Analytics, you had to manually add your own domain to the "Referral Exclusion List" to prevent self-referrals. In GA4, when you complete the "Configure your domains" step above, GA4 automatically handles this for you. Your root domain is added to what GA4 calls a list of "unwanted referrals." There's no extra step required.
How to View Subdomain Data in Your GA4 Reports
Now that your data is being collected correctly, you need to know how to find it in your reports. By default, GA4's Pages report only shows you the page path (e.g., /pricing), not the full URL or the subdomain (e.g., blog.yourdomain.com/some-post).
To differentiate traffic between your main site and your subdomains, you need to use the Hostname dimension.
Customizing Your Pages Report
The easiest way to see performance by subdomain is to customize the default Pages and screens report.
- Navigate to Reports → Engagement → Pages and screens.
- Click the pencil icon (Customize report) in the top-right corner of the report.
- On the right panel, under Report Data, click on Dimensions.
- Click Add dimension and search for or select Hostname.
- Drag the Hostname dimension and drop it above
Page path, making it the new primary dimension. Click Apply. - Click Save, then choose Save as a new report. Give it a memorable name, like "Pageviews by Hostname". Access this custom report later from the Library section of your GA4 property.
Now, when you view this new report, the primary dimension will be the hostname (yourdomain.com, blog.yourdomain.com, etc.), allowing you to see metrics for each subdomain and drill down to see individual pages within each one.
Tips for Exploration Reports
For more flexible analysis, use the Explore section. Here you can build custom reports from scratch.
Try creating a free-form exploration with:
- Rows:
Hostname - Columns:
Session source / medium - Values:
Sessions,Total users,Conversions
This layout gives you a powerful pivot table showing which traffic channels are driving users to your various subdomains, and which are generating the most conversions. It’s a great way to understand exactly how different parts of your site are contributing to your business goals.
Final Thoughts
Properly tracking your subdomains in Google Analytics 4 is no longer a complex technical headache. By ensuring a single tracking tag across your sites and performing a one-time configuration of your domains, you can transform broken analytics into a unified, coherent view of the complete customer journey. This clean data allows for accurate attribution, clearer insights into content performance, and ultimately, smarter marketing decisions based on how users truly interact with your brand.
Stitching together data across platforms is a core challenge for any team that wants a clear view of their performance. We built Graphed to solve this by making sophisticated data analysis simple and accessible. Instead of building custom reports to analyze subdomain traffic in GA, you can connect your Google Analytics account and ask questions like "Chart the number of sessions from the blog versus the main site for the last quarter." It builds live, interactive dashboards using plain English, so you can unify your data from dozens of sources and an answer in seconds, not hours. Feel free to give Graphed a try and see for yourself.
Related Articles
What SEO Tools Work with Google Analytics?
Discover which SEO tools integrate seamlessly with Google Analytics to provide a comprehensive view of your site's performance. Optimize your SEO strategy now!
Looker Studio vs Metabase: Which BI Tool Actually Fits Your Team?
Looker Studio and Metabase both help you turn raw data into dashboards, but they take completely different approaches. This guide breaks down where each tool fits, what they are good at, and which one matches your actual workflow.
How to Create a Photo Album in Meta Business Suite
How to create a photo album in Meta Business Suite — step-by-step guide to organizing Facebook and Instagram photos into albums for your business page.