How to Track Subdomain in Google Analytics 4

Cody Schneider7 min read

Tracking users as they jump between your main website and its subdomains - like from yourbrand.com to blog.yourbrand.com - can feel like trying to solve a puzzle. The good news is that with Google Analytics 4, getting a complete picture of this journey is easier than ever. This guide will walk you through exactly how to set up and verify cross-subdomain tracking in GA4, so you can stop guessing and start seeing the full customer journey.

GraphedGraphed

Still Building Reports Manually?

Watch how growth teams are getting answers in seconds — not days.

Watch Graphed demo video

Why Is Tracking Subdomains So Important?

Imagine a typical user's path. They might land on a blog post at blog.yourbrand.com from a Google search, click a link to learn more about your product on your main site at www.yourbrand.com, and finally make a purchase on your store at shop.yourbrand.com.

Without proper cross-subdomain tracking, Google Analytics might misinterpret this journey. It could see these as three separate visitors from three different sources, each one "bouncing" when they move to the next property. This leads to a few major data problems:

  • Inflated User Counts: A single, engaged user is counted as multiple new users, skewing your audience metrics.
  • Inaccurate Funnel Analysis: Your conversion funnels will appear broken, as you can't see the seamless transition from discovery to purchase.
  • Lost Attribution: The original source that brought the user to your blog doesn't get credit for the final sale that happened on your shop. Your marketing campaign data becomes unreliable.

By setting this up correctly, you’ll get a single, unified view of each user's session, no matter which of your subdomains they visit.

GraphedGraphed

Still Building Reports Manually?

Watch how growth teams are getting answers in seconds — not days.

Watch Graphed demo video

GA4 and Subdomains: A Welcome Change

If you have experience with the older Universal Analytics (UA), you probably remember having to make code changes or set up tricky referral exclusion lists to get subdomain tracking to work. It was a common headache that required technical adjustments.

GA4 simplifies this immensely. By default, GA4 sets its cookies on the highest-level domain possible (the eTLD+1). This means if your site is yourbrand.com, the cookie is set there. This allows a single cookie to be recognized across www.yourbrand.com, blog.yourbrand.com, and any other subdomain you have. Because of this, GA4 automatically handles the core part of cross-subdomain tracking without you having to do much at all.

However, there is one crucial step you need to take to ensure everything is formally defined in your setup. This tells GA4 explicitly that traffic moving between these domains should be considered internal.

Setting Up Cross-Subdomain Tracking in GA4

There’s only one primary place you need to check and configure within your GA4 property to make sure this works flawlessly.

Step 1: Configure Your Domains in the Web Data Stream

This setting helps GA4 understand which domains belong to you. By defining them here, you ensure that GA4 doesn’t treat a click from your blog to your main site as a referral. Here's how to do it:

  1. Navigate to the Admin section of your GA4 property (the gear icon ⚙️ at the bottom-left).
  2. In the Property column, click on Data Streams.
  3. Click on the web data stream for which you want to configure tracking.
  4. Under Google tag, click on Configure tag settings.
  5. In the Settings section, click Show more if needed, then find and click on Configure your domains.
  6. You'll see a configuration screen. This is where you list all domains that encompass a single user journey for your business. You don’t need to add every single subdomain. Instead, you can create one simple rule.
  7. Click Add condition.
  8. Set the Match type to contains.
  9. For the Domain, enter your root domain (e.g., yourbrand.com).

By using "contains" and your root domain, you're creating a simple rule that covers your main domain (www.yourbrand.com) and every possible subdomain (blog.yourbrand.com, shop.yourbrand.com, app.yourbrand.com, etc.). That’s it! Click Save.

Note: If you were previously using a referral exclusion list from Universal Analytics, GA4 likely migrated it here automatically. It’s always a good idea to check this setting to confirm it meets your needs.

GraphedGraphed

Still Building Reports Manually?

Watch how growth teams are getting answers in seconds — not days.

Watch Graphed demo video

Step 2: Verify Your Setup with DebugView

Now that you've configured the setting, you should verify that it's working as expected. GA4’s built-in DebugView is the perfect tool for this.

  1. Install the Google Analytics Debugger Extension: This is a free Chrome extension that enables debug mode in GA4. Once installed, turn it on by clicking its icon in your extensions tray.
  2. Navigate to DebugView in GA4: In your GA4 Admin panel, go to DebugView under the Property column.
  3. Test the User Journey: Open your website on the primary domain (e.g., www.yourbrand.com) in a new tab. You should immediately see events start appearing in DebugView from your device.
  4. Switch to a Subdomain: Now, navigate from your main site to one of your subdomains by clicking a link (e.g., go to blog.yourbrand.com).
  5. Check the Session ID: Watch the events as they come into DebugView. Click on a page_view event before you switched domains and look for a parameter called ga_session_id. Note its value. Now, click on a page_view event that occurred after you landed on the subdomain. The ga_session_id should be the exact same value. If it is, congratulations! This confirms GA4 is maintaining a single session across your subdomains. The page_location parameter should be different, reflecting the new subdomain URL, but the session remains intact.

How to See Subdomain Data in Your GA4 Reports

Just setting up the tracking is half the battle. Now you need to know how to actually view the performance data for each subdomain in your GA4 reports.

By default, many GA4 reports like the Pages and Screens report will only show the page path (e.g., /awesome-blog-post). This can be confusing. Did that view happen on your blog subdomain or somewhere else? The key to solving this is the Hostname dimension.

Method 1: Add 'Hostname' as a Secondary Dimension

This is the quickest way to see which subdomains are driving traffic on standard reports.

  1. Navigate to Reports > Engagement > Pages and Screens.
  2. By default, you’ll see a list of page paths and their view counts.
  3. Click the blue plus icon (+) next to the primary dimension (which is "Page path and screen class") to add a secondary dimension.
  4. In the search box, type and select Hostname.

The report will reload with a new Hostname column. Now you can clearly see the domain or subdomain (e.g., www.yourbrand.com or blog.yourbrand.com) associated with each page path, giving you full clarity on where your traffic is going.

GraphedGraphed

Still Building Reports Manually?

Watch how growth teams are getting answers in seconds — not days.

Watch Graphed demo video

Method 2: Create a Custom Report in Explorations

For more detailed and reusable analysis, building a custom report in GA4's Explorations is the best approach.

  1. Go to the Explore section in the left-hand navigation and start a new Free-form exploration.
  2. In the Variables column on the left, click the plus icon (+) next to Dimensions. Search for and import both Hostname and Page path and screen class.
  3. Next, click the plus icon (+) next to Metrics. Search for and import the metrics you care about, such as Active users, Views, and Conversions.
  4. Now, drag your dimensions and metrics into the Tab Settings column:

Instantly, you'll have a clean, easy-to-read custom table that shows the performance of every page, neatly organized by its subdomain. You can name this Exploration "Page Performance by Subdomain" and come back to it whenever you need.

Final Thoughts

Properly tracking your user journey across subdomains provides a single source of truth for your website's performance. By correctly configuring your data stream in GA4 and using the Hostname dimension in your reports, you gain a complete understanding of how users interact with your entire digital ecosystem and accurately attribute a conversion back to its original source.

Once you have all that rich GA4 data flowing in correctly, the next challenge is quickly turning it into actionable insights without spending hours building reports. That's exactly why we created Graphed. We simplify the whole process by letting you connect your Google Analytics account and then use plain English to ask questions like, "Show me my top 10 pages on the blog separated by hostname" or "Compare traffic sources between my main site and my shop this month." Instead of manually building reports, you get the dashboards and answers you need in seconds, all updated in real-time.

Related Articles