How To Add a SubDomain To Google Analytics
When you run multiple subdomains under your main website, tracking their performance separately becomes essential for understanding user behaviour across your entire digital presence. You can add subdomains to Google Analytics by modifying your GA4 configuration to include cross-domain tracking and setting up proper filters to distinguish traffic between your main domain and subdomains. Many website owners miss valuable insights because they assume subdomain tracking happens automatically.

Setting up subdomain tracking isn’t as complex as it might seem, but it requires specific steps to ensure accurate data collection. The process differs significantly between GA4 and the older Universal Analytics, with GA4 offering more streamlined options for tracking multiple domains under one property.
This guide will walk you through the complete process of configuring subdomain tracking in Google Analytics 4, from initial planning through to analysing your subdomain data. You’ll learn how to implement tracking through both direct GA4 setup and Google Tag Manager, plus how to verify everything works correctly and troubleshoot common issues.
Understanding Subdomain Tracking in Google Analytics
Subdomain tracking lets you see how visitors move between different parts of your website structure, whilst subdomain data helps you understand user behaviour across your entire web presence.
Definition and Structure of Subdomains
A subdomain is a separate section of your main website that sits before your primary domain name. Common examples include blog.yoursite.co.uk or shop.yoursite.co.uk.
My subdomain is shop.cosmictouchblog.com and the main site (the one you’re on now) is cosmictouchblog.com.
Subdomains work like folders in your website structure. They help organise different areas of your business or content types.
Your main domain might be “example.co.uk” whilst your subdomains could be:
- support.example.co.uk
- store.example.co.uk
- news.example.co.uk
Each subdomain can have its own pages and content. They share the same root domain but operate as distinct sections.
How Google Analytics Handles Subdomain Tracking
Google Analytics 4 tracks subdomains automatically by default. This means subdomain traffic appears in your main property without extra setup.
The system treats all subdomains as part of the same website. User sessions continue when visitors move from your main site to a subdomain.
Key tracking behaviours:
- Sessions remain unbroken across subdomains
- User paths show complete journeys
- Referral traffic excludes internal subdomain movements
Google Analytics sees “yoursite.co.uk” and “blog.yoursite.co.uk” as the same property. This creates seamless tracking across your entire web presence. Basically you don’t need to do anything!
Benefits of Subdomain Tracking
Proper subdomain tracking gives you complete visibility into user behaviour across your website structure. You can see how visitors use different areas of your site.
Main advantages include:
- Complete user journeys: Track paths from main site to blog or shop
- Better conversion data: See which subdomains drive sales or leads
- Improved content insights: Understand how subdomain content performs
Subdomain data helps you make better decisions about website structure and content strategy. You can identify which subdomains work best for different goals.
This tracking method also prevents inflated session counts. Without it, moves between subdomains would appear as separate visits from new users.
Differences Between GA4 and Universal Analytics for Subdomain Tracking
GA4 handles subdomain tracking very differently than Universal Analytics, with automatic session stitching replacing manual referral exclusions. The new system simplifies setup but removes the ability to create separate views for individual subdomains.
Key Changes in GA4
GA4 automatically tracks subdomains under the same property without additional configuration. This is a major change from Universal Analytics, where you needed manual setup.
In Universal Analytics, you had to modify tracking codes and configure cross-domain settings. GA4 eliminates this complexity by treating all subdomains as part of the same website automatically.
GA4 removes the ability to create separate views for subdomains. Universal Analytics allowed you to filter data by subdomain using views. GA4 only offers property-level tracking.
You must now use segments or filters in reports to separate subdomain data. This change means less flexibility but simpler initial setup.
The event-based tracking model in GA4 also affects how subdomain interactions are recorded. Sessions flow seamlessly between subdomains without breaking.
Session Stitching Across Subdomains
GA4 automatically stitches sessions across subdomains without losing user data. When someone moves from your main site to a subdomain, GA4 treats it as one continuous session.
Universal Analytics often created new sessions when users moved between subdomains. This caused inflated session counts and broken user journeys in your reports.
Session continuity in GA4 provides more accurate user journey data. You can see the complete path users take across all your subdomains.
The improved session handling means better conversion tracking. If someone starts on your blog subdomain and completes a purchase on your shop subdomain, GA4 correctly attributes the conversion.
This automatic stitching works through enhanced measurement and the gtag.js library. No additional coding is required on your part.
Referral Exclusion in Universal Analytics
Universal Analytics required you to add subdomains to the referral exclusion list manually. Without this step, traffic between subdomains appeared as referral traffic in reports.
You had to configure the referral exclusion list for each subdomain you wanted to track together. Missing even one subdomain caused data problems.
GA4 eliminates the need for manual referral exclusions for subdomains. The system handles this automatically during implementation.
In Universal Analytics, forgetting to exclude a subdomain meant seeing it as an external traffic source. This created confusing reports and incorrect attribution.
The automatic handling in GA4 reduces setup errors and provides cleaner data from the start. Your subdomain traffic appears correctly classified without manual intervention.
Preparation: Prerequisites and Planning for Subdomain Tracking
Setting up subdomain tracking requires proper DNS configuration and a thorough review of your current Google Analytics setup. These foundational steps ensure accurate data collection across all subdomains.
Ensuring Proper DNS and Website Configuration
Your DNS records must be correctly configured before implementing subdomain tracking. Each subdomain needs an active DNS entry pointing to the appropriate server or IP address.
Verify that all subdomains are accessible and loading properly. Test each subdomain URL in your browser to confirm they display content without errors.
Check your website’s technical setup across all subdomains. Ensure that:
- SSL certificates cover all subdomains you plan to track
- CDN settings don’t interfere with tracking scripts
- Server configurations allow JavaScript execution
Document all active subdomains you want to include in tracking. Create a list with the following information:
| Subdomain | Purpose | Priority Level |
|---|---|---|
| blog.example.co.uk | Content marketing | High |
| shop.example.co.uk | E-commerce | High |
| support.example.co.uk | Customer service | Medium |
Auditing Existing Google Analytics Implementation
Review your current Google Analytics setup to identify potential conflicts. Check if you’re using Google Tag Manager or direct tracking code implementation across your domains.
Examine your existing tracking code placement. Look for multiple Google Analytics properties or duplicate tracking codes that could cause data issues.
Document your current Google Analytics property structure. Note which domains and subdomains are already being tracked and how they’re configured.
Identify any custom dimensions, events, or goals that need to work across subdomains. These configurations may require updates once subdomain tracking is active.
Check your referral exclusion list in Google Analytics. You’ll need to add your main domain to prevent subdomains from appearing as referral traffic.
How to Add a Subdomain to Google Analytics 4
Setting up subdomain tracking in GA4 requires configuring your existing data stream to work across all subdomains. You’ll need to access your GA4 property’s admin settings and ensure your measurement ID is properly implemented across all subdomain pages.
Accessing Your GA4 Admin Settings
Navigate to your Google Analytics account and select the GA4 property you want to configure. Click the Admin button in the bottom left corner of your interface.
You’ll see three columns: Account, Property, and Data Stream. Make sure you’re working with the correct GA4 property before proceeding.
Select Data Streams from the Property column. This section shows all the data streams connected to your GA4 property.
Click on your existing web data stream. This opens the stream details where you can view your measurement ID and configure settings.
Adding a New Data Stream for Subdomains
GA4 handles subdomain tracking differently than Universal Analytics. You don’t need to create separate data streams for each subdomain.
Your existing web data stream can track multiple subdomains automatically. Click on your current data stream to view its configuration.
In the stream details, look for the Website URL field. Your main domain should already be listed here.
GA4 will automatically collect data from any subdomain that uses the same GA4 measurement ID. You don’t need to add each subdomain manually to the data stream settings.
Configuring Measurement ID and Tracking Code
Copy your GA4 measurement ID from the data stream details page. It starts with “G-” followed by letters and numbers.
Add the Google Analytics tracking code to every page across all your subdomains. Use the same measurement ID for your main domain and all subdomains.
If you’re using Google Tag Manager, create a single GA4 Configuration tag. Set the trigger to fire on all pages across all subdomains you want to track.
Verify your setup by checking real-time reports in GA4. Visit different subdomains and confirm that traffic appears in your reports. The data should flow into your single GA4 property automatically.
Implementing Subdomain Tracking via Google Tag Manager
Google Tag Manager provides the most efficient method for tracking subdomains in GA4. You’ll need to configure a GA4 tag with specific settings and deploy it across all your domains.
Setting Up a GA4 Configuration Tag
Start by creating a new GA4 Configuration tag in your Google Tag Manager container. Navigate to Tags and click New.
Select GA4 Configuration as your tag type. Enter your GA4 Measurement ID in the configuration field.
The most critical setting is the Cookie Domain field. Set this to auto to ensure cookies work properly across your main domain and all subdomains.
Configure the Fields to Set section with these parameters:
- cookie_domain: auto
- cookie_flags: SameSite=None;Secure
Set your trigger to All Pages so the tag fires on every page load. This ensures consistent tracking across your entire site structure.
Save your configuration tag with a clear name like “GA4 – Subdomain Config”. This tag will handle all basic tracking for both your main domain and subdomains.
Deploying Tags Across Subdomains
Install the same GTM container code on your main domain and all subdomains. The container snippet must appear on every page you want to track.
Add the GTM code to the <head> section of each subdomain. If you’re using a content management system, consider installing GTM through a plugin for easier management.
Important: Use only one GTM container across all domains. Don’t create separate containers for each subdomain as this will fragment your data.
Test that the container loads correctly on each subdomain by checking the Preview Mode in Google Tag Manager. The same tags should fire consistently across all domains.
Publish your GTM container once you’ve verified everything works properly. This ensures your GA4 configuration tag becomes active across all your domains simultaneously.
Testing Tag Implementation
Use Google Tag Assistant or the browser console to verify your tags fire correctly. Check that the GA4 configuration tag triggers on both your main domain and subdomains.
Monitor the Real-time reports in your GA4 property. Navigate between your main site and subdomains whilst watching for consistent user tracking.
Verify that users moving between domains maintain the same Client ID. This appears in the GA4 DebugView when you enable debug mode in GTM.
Check your cookie settings using browser developer tools. The GA4 cookies should have the correct domain scope (starting with a dot) to work across subdomains.
Test conversion tracking by completing actions that span multiple subdomains. The user journey should appear as a single session in your GA4 reports.
Verifying and Troubleshooting Subdomain Tracking in GA4
Proper subdomain tracking requires regular verification through real-time reports and hostname data. Most issues stem from incorrect configuration or session handling problems between subdomains.
Checking Real-Time and Hostname Reports
Real-time reports show if your subdomain tracking works correctly. Navigate to Reports > Realtime in GA4 to see active users across your domains.
Check the hostname dimension to verify traffic from each subdomain appears separately. Click on any real-time event to view detailed information.
Look for your main domain and subdomains in the hostname field. You should see entries like:
- example.com
- shop.example.com
- blog.example.com
Test your setup by visiting each subdomain whilst monitoring real-time reports. Each visit should register within 30 seconds.
If subdomains don’t appear, check your Google Tag installation on each subdomain. The tracking code must be present on every page you want to monitor.
Use the Tag Assistant tool to verify proper tag firing. Access this through Admin > Data Streams > your stream > Tag Assistant.
Resolving Common Tracking Issues
Missing subdomain data usually means the Google Tag isn’t installed correctly. Check each subdomain’s source code for the GA4 tracking snippet.
Duplicate sessions occur when cross-domain measurement isn’t configured properly. Add all subdomains to your exclusion list in GA4 settings.
Inconsistent user tracking happens when cookie settings differ between subdomains. Ensure your Google Tag uses the same measurement ID across all domains.
Configuration problems often involve:
- Wrong measurement ID on subdomain pages
- Missing Google Tag Manager containers
- Incorrect domain settings in GA4
Debug issues using browser developer tools. Check the Network tab for gtag requests when loading subdomain pages.
Data stream configuration errors prevent proper tracking. Verify each subdomain uses the same web data stream in your GA4 property.
Addressing Cross-Subdomain Session Problems
Cross-subdomain tracking issues create artificial session breaks when users move between subdomains. This inflates session counts and reduces accuracy.
Configure cross-domain measurement in GA4 Admin settings. Add all your subdomains to the domain list under Data Streams.
Session continuity problems show as:
- Multiple sessions for single user journeys
- Referral traffic between your own subdomains
- Inflated bounce rates
Cookie domain settings affect cross-subdomain tracking. The Google Tag should set cookies at the root domain level to work across subdomains.
Test session continuity by navigating between subdomains. Use real-time reports to confirm the same user ID continues across domains.
Check your referral exclusion list includes all subdomains. Traffic between excluded domains won’t create new sessions unnecessarily.
Timing issues can disrupt cross-subdomain tracking. Ensure your Google Tag loads completely before users can navigate to other subdomains.
Analysing Subdomain Traffic and User Engagement
Once subdomain tracking is set up, you need to examine how visitors interact with each subdomain separately. This analysis requires custom segments and tailored reports to understand performance differences across your various subdomains.
Using Hostname and Custom Segments
Custom segments help you separate traffic from different subdomains in your reports. You can create segments based on hostname to view specific subdomain performance.
Navigate to your GA4 property and select Audiences from the left menu. Click New Audience and choose Custom Audience.
Set up your segment conditions:
- Dimension: Hostname
- Condition: Contains or Exactly matches
- Value: Your subdomain (e.g., blog.yoursite.com)
Save the segment with a clear name like “Blog Subdomain Traffic”. This segment will filter all reports to show only data from that specific subdomain.
You can create multiple segments for each subdomain you want to track. Apply these segments to any GA4 report to compare performance between different parts of your website.
Creating Custom Reports for Subdomain Performance
Custom reports show subdomain-specific metrics that standard reports might miss. These reports help you understand which subdomains drive the most engagement and conversions.
Build a custom report by going to Explore in GA4. Choose Free Form exploration to create your subdomain report.
Add these dimensions to your report:
- Hostname (primary dimension)
- Page title or Page location
- Source/Medium
Include these key metrics:
- Sessions
- Engaged sessions
- Average engagement time
- Conversions (if applicable)
This report structure shows how each subdomain performs across different traffic sources. You can see which subdomains keep visitors engaged longest and which ones convert best.
Apply date comparisons to spot trends in subdomain performance over time.
Data-Driven Decisions and Insights
Subdomain data reveals patterns that guide website improvements and resource allocation. Use this information to make informed choices about content strategy and technical changes.
Look for these key insights in your subdomain analysis:
Engagement patterns – Compare average session duration and bounce rates between subdomains. High-performing subdomains show what content resonates with your audience.
Traffic sources – Some subdomains might perform better with organic search whilst others work well for social media traffic.
Conversion rates – Track which subdomains lead to desired actions like sign-ups or purchases.
Use these insights to optimise underperforming subdomains. Copy successful elements from high-engagement subdomains to improve weaker areas.
Regular analysis helps you spot technical issues early. Sudden drops in subdomain traffic often indicate broken links or server problems that need fixing.
Frequently Asked Questions
Setting up subdomain tracking requires specific configuration steps in GA4 and proper implementation through Google Tag Manager. Common issues include data attribution problems and incorrect cross-domain settings that prevent accurate reporting.
What steps are required to track multiple subdomains in Google Analytics?
You need to configure your GA4 property to recognise traffic across all your subdomains as part of the same website. Start by accessing your GA4 property settings and navigate to the data streams section.
Create a single GA4 property for your main domain and all subdomains. Add each subdomain URL to your data stream configuration within the same property.
Install the same GA4 tracking code on every subdomain you want to monitor. Use identical measurement IDs across all domains to ensure proper data collection.
Configure your cookie domain settings to work across subdomains. Set the cookie domain to your root domain with a leading dot, such as “.yourdomain.com”.
How can I differentiate between data from various subdomains in my GA4 reports?
GA4 automatically captures hostname data that shows which subdomain generated each session or event. You can view this information in your reports under the “Page location” and “Page title” dimensions.
Create custom audiences based on hostname to segment users from specific subdomains. Navigate to the Audiences section and set up filters using the hostname dimension.
Use the “Pages and screens” report to see traffic breakdown by subdomain. Filter the report by hostname to focus on specific subdomain performance.
Set up custom events that include subdomain information as parameters. This allows for more detailed analysis of user behaviour across different subdomains.
What configuration changes need to be made in GA4 for accurate subdomain tracking?
Modify your data stream settings to include all subdomain URLs you want to track. Add each subdomain as an additional URL in your web data stream configuration.
Update your referral exclusion list to include your main domain and all subdomains. This prevents GA4 from treating subdomain traffic as external referrals.
Configure your cookie settings to share data across subdomains. Set your cookie domain to your root domain with proper wildcard formatting.
Enable enhanced measurement features for consistent tracking across all subdomains. Turn on page views, scrolls, outbound clicks, and file downloads for comprehensive data collection.
Is there a specific method for setting up cross-domain tracking with GA4?
Cross-domain tracking in GA4 requires adding all domains to your referral exclusion list. Access your data stream settings and add each domain you want to track together.
Install the same GA4 measurement ID on all domains you want to connect. Use identical tracking codes to ensure proper session attribution.
Configure your linker settings if users navigate between domains through clicks. Add the domains to your Google Tag Manager configuration or GA4 settings.
Test your setup by navigating between domains and checking that sessions continue properly. Use GA4’s real-time reports to verify data attribution works correctly.
When implementing Google Tag Manager, how do I ensure subdomain tracking works correctly?
Set up your GA4 configuration tag with the proper cookie domain settings. Configure the cookie domain field to your root domain with a leading dot.
Create triggers that fire on all subdomains you want to track. Set your trigger conditions to match your subdomain URLs properly.
Configure your GTM container to work across subdomains. Install the same container code on every subdomain you want to monitor.
Use GTM’s preview mode to test tracking across different subdomains. Verify that tags fire correctly and data appears in your GA4 real-time reports.
Why might my setup for cross-domain tracking in GA4 not be reporting data as expected?
Your referral exclusion list might be incomplete or incorrectly configured. Check that all domains and subdomains appear in your exclusion settings.
Different measurement IDs across domains will break cross-domain tracking. Verify that identical GA4 tracking codes exist on all domains you want to connect.
Cookie domain settings may prevent proper data sharing between subdomains. Ensure your cookie domain is set to your root domain with correct formatting.
Ad blockers and privacy settings can interfere with cross-domain tracking functionality. Test your setup using different browsers and incognito modes to identify blocking issues.
