
September 2, 2025
Subdomain Tracking with Google Analytics 4
Updated: September 2nd, 2025
If you are working with a business that operates on multiple subdomains (e.g., blog.business.com, support.business.com, www.business.com, etc.), you will most likely want to track website visitors with Google Analytics 4 across all these websites.
If yes, what configurations do you need to have a proper setup? The good news is that the process is pretty simple. Nevertheless, there are several things to keep in mind.
In today’s blog post, I’ll show you how to implement subdomain tracking with Google Analytics 4.
Table of Contents
Here’s what you will learn in this article
- Subdomains DO NOT require cross-domain tracking
- Subdomain tracking: SHORT VERSION
- Subdomain tracking: LONG VERSION
- #1. It’s all about the cookies
- #2. You must use the same GA4 property and web data stream for all subdomains
- #3. Test if your GA4 subdomain tracking works
- #4. What if you see self-referrals?
- #5. Finding full page URLs in GA4
- #6. Landing pages of each subdomain
- #7. Seeing subdomain data with comparisons
- Final Words
Video tutorial
If you prefer video content, here’s the tutorial from my YouTube channel. The GA4 interface has changed since I recorded this video, but the concept remains unchanged.
Note: at 1:13 of that video, I added a quick note “Or at least the same GA4 property” at the top of the screen. With my current knowledge, I can confirm that you must use the same measurement ID in GA4 subdomain tracking.
Before we start: Subdomains DO NOT require cross-domain tracking
Sometimes, I see forum threads or chats asking how to implement cross-domain tracking for their project/websites when it turns out that the business operates on a single domain (just different subdomains).
So before we dive deeper into the actual details, here’s a public social announcement:
YOU DO NOT NEED CROSS-DOMAIN TRACKING FOR SUBDOMAINS OF THE SAME DOMAIN
If you are dealing with subdomains like:
- www.example.com
- blog.example.com
- support.example.com
Then you DO NOT need to implement cross-domain tracking because all of them belong to the same example.com domain
However, you WILL MUST to implement cross-domain tracking if you’re working with separate domains, e.g.:
- www.mainwebsite.com
- blog.example.com
- support.someotherdomain.com
And that’s about it. Now, let’s move to the subdomain tracking with Google Analytics 4.
P.S. but if you configure your subdomains in the “Configure your domains” section (this is part of the cross-domain tracking), nothing wrong will happen. So if you *really* want, you can do it nevertheless.

Subdomain tracking with Google Analytics 4: THE SHORT VERSION
There are several things to remember while tracking subdomains with Google Analytics 4. Let’s start with the short version (for those in a hurry). If you find some of these tips confusing, please read the long version).
1. First, Google Analytics 4 handles subdomains automatically if GA4 is installed on all those subdomains. GA4 supports a parameter called cookie_domain. The default value of it is auto. This means that GA cookies will remain the same across all subdomains of the same domain.
2. You will need to make sure that you use the same GA4 property and the same web data stream across all subdomains you want to measure. In other words, all subdomains must use the same GA4 measurement ID. The requirement for the same data stream is mentioned in the documentation of GA4 cross-domain tracking. The same applies to subdomain tracking.
3. You *might* need add your main domain to the list of GA4 unwanted referrals. Normally, Google Analytics 4 should handle self-referrals automatically. But if you see (for some reason) your subdomains in the Traffic Acquisition reports as referring domains, include your domain in the list of unwanted referrals. You can do that by going to Admin > Data Stream > Select web data stream > Configure Tag Settings > Show all > List unwanted referrals and enter your main domain there.

Subdomain tracking with GA4: THE LONG VERSION
Now, let’s move on to the longer version with a thorough explanation.
#1. It’s all about the cookies
Google Analytics tracking is based on first-party cookies. Whenever a visitor lands on a page, the Google Analytics 4 tracking snippet is activated on a page that stores two cookies: _ga (with a randomly generated ID + timestamp) and _ga_[measurement_id] (with the GA session ID and some other stuff, for example, _ga_BOF93NIS87).
When you continue browsing the website, GA keeps checking those cookies. If they exist, GA4 reuses the ID from the _ga cookie and session id from _ga_[measurement_id]. Then GA understands that you are the same person who just made a page view a few minutes ago and if it’s still the same session.
So if you return to the website, GA will continue to understand that this is the same visitor who was on the website before.
However, if the cookies are not present (or are not available for that particular domain (or subdomain)), then new _ga and _ga_[measurement_id] cookies will be created.
I highlighted several words in the previous sentence for a reason.
You see, setting a cookie just for a particular subdomain is possible (with the cookie_domain parameter). In that case, only that subdomain (and subdomains of that subdomain) can access the cookie. This can also apply to the _ga cookie.
Here’s an example of a cookie set for all .example.com. This means that any subdomain of example.com can access that particular cookie. GA4 sets such a cookie by default.
However, if the _ga cookie is created only for demo.example.com, then its value can be accessed only by:
- demo.example.com
- v1.demo.example.com (or any other subdomain that is on the lower level of demo.example.com)
But www.example.com will NOT be able to access the cookie (because www and demo are different subdomains of the same level).
Luckily, the default behavior of GA4 tracking code and cookies is convenient because cookies are set on .example.com, which means that all subdomains of example.com will be able to access that cookie. The dot before the domain is essential here.
This automatic behavior is possible because of a default setting in Google Analytics called cookie_domain: ‘auto’. You can think of this as a smart rule that tells GA to set its tracking cookie on the highest-level domain possible. So, instead of placing a cookie that only works for blog.example.com, the ‘auto’ setting intelligently places it on .example.com. This simple but powerful feature is what allows the same visitor to be recognized as they move seamlessly between your main website and all its subdomains.

#2. You must use the same GA4 property and web data stream for all subdomains
Even though GA4 sets cookies for all subdomains by default, you must use the same GA4 property and data stream across all subdomains. Do not create separate data streams for each subdomain. Use one for all of them.
This might sound confusing for GA4 beginners, but that’s how it works. You might be wondering what domain you should enter here (in the data stream settings):
The answer is to enter any (sub)domain you want. It does not matter much. Even if you entered X subdomain in the data stream’s settings, that stream’s measurement ID can still be installed on multiple websites, and GA4 will work just fine.
I don’t have specific evidence of why that is needed, but I think it should be related to sessions (except that this requirement was mentioned in the cross-domain tracking documentation). As mentioned, GA4 sets two cookies: _ga and _ga_[measurement_id]. The 2nd cookie contains the session ID. And if you have multiple data streams (one for each subdomain), you will end up having a bunch of different _ga_[measurement_id] cookies, e.g.,
- _ga_W6QB81P632
- _ga_ZBXB89P3NI
- _ga_TOP8R93ZE9
However, your goal should be that all GA cookies (not just _ga) contain consistent values across subdomains. That’s why one web data stream should be the way to go.
There’s one drawback, though (if you have one data stream for multiple subdomains), Google Search Console integration.
One data stream can be connected only to one GSC property. So, if you have separate Search Console properties for each subdomain, you can connect only one with GA4. However, I prefer using the search console via its native interface (not via GA4), so I don’t find this drawback a dealbreaker.

#2.1. What about the GTM container?
Should you use the same for all subdomains? Or should you create different containers for each subdomain?
The answer is: it does not matter. Your GTM account and container structure have no direct impact on subdomain tracking in Google Analytics.
The decision to use one or multiple GTM containers often comes down to teamwork and complexity. If your subdomains are very similar and managed by the same team, a single container is usually more efficient. However, if your blog, main site, and support portal are managed by different teams or have vastly different tracking needs, using separate containers can be a safer and cleaner approach. This prevents one team’s work from accidentally impacting another’s, even though all containers will still correctly send data to your one central GA4 property.
Here is my rule of thumb:
- If you have multiple subdomains and all those websites are VERY similar, you can use a single GTM container for all of them.
- If your websites on those subdomains are quite distinct and serve different purposes (e.g., a blog, the main website, a support center, etc.), I recommend using separate GTM containers.
However, once again, I’d like to emphasize this — what matters is that data must be sent to the same GA property and data stream if you want to track the same people across multiple subdomains. In other words, all GTM containers must send data to the same GA4 measurement ID.
If you are still unsure how many GTM containers you need, read this guide.
#2.2. How do you decide which subdomains should be tracked in a single GA property?
Answer this: do you want to see your visitors of an X subdomain in your GA reports together with other subdomains? If yes, you need to track that subdomain in the same property.
That’s it. We have just decided that together with you 🙂
#3. Test if your GA4 subdomain tracking works
Once you have installed the same GA4 property (with the same measurement ID) on all subdomains, it’s time to test.
First, go to the subdomain A and open developer tools (in Google Chrome, that can be found by clicking three dots at the top right corner and then going to More tools > Developer Tools).
Then go to Application > Cookies > select your subdomain. In the search field, enter _ga. Her,e you should see at least two cookies:
- _ga
- and _ga_[your measurement id], e.g., _ga_ABC1234567 (the “G-” from your measurement ID is ignored here)
Check if their domain starts with a dot and that domain is yours. For example, if you are now on blog.example.com, the domain should be .example.com .
Now, go to another subdomain. Check the same thing. The values of GA4 cookies should be the same between subdomains.
Then you can also enable this Chrome extension and go to GA4 admin > Debugview. Find your device there and see if events from multiple subdomains are included in the same stream of one user.
#4. What if you see self-referrals?
Normally, Google Analytics handles self-referrals automatically. So if a visitor goes from subdomain1.example.com to subdomain2.example.com, subdomain1.example.com will not be displayed in the Traffic acquisition reports as one of the traffic sources.
But in rare cases, I have seen that the opposite happens – you start seeing your subdomains as traffic sources. If you also face this issue, update the list of unwanted referrals.
Seeing your own domain as a traffic source can be confusing, as it hides the true origin of your visitors. For example, if a user comes from a Google ad to shop.example.com and then clicks a link to blog.example.com, you want Google Analytics to remember they came from the ad. If a self-referral issue exists, the traffic source might be incorrectly overwritten to shop.example.com. Adding your main domain to the unwanted referrals list tells GA4 to ignore these internal movements and preserve the original traffic source information. You can also learn more about self referrals here.
Go to GA4 admin > Data Streams > Select your web data stream > Configure Tag Settings > Show More > List unwanted referrals and then enter your main domain there.
For example, if your subdomains are subdomain1.example.com and subdomain2.example.com, then enter example.com in the settings of GA4. Save the changes.
#5. Finding full Page URLs in GA4
One of the default dimensions that is displayed in standard GA4 reports is Page Path. It shows the part of the URL that comes after the hostname (e.g.,/pages/contact/). But what if multiple subdomains have the same page path (e.g., the homepage of both subdomains will be displayed as / )?
In that case, you have several options.
The first one is to add the secondary dimension (hostname) to the standard report. You can do that by clicking the Plus icon in the report and finding that dimension.
Another option is to use the Page Location dimension. It shows the full URL (including hostname and query parameters). For example, you can customize the standard report and include Page location as one of your dimensions.
However, remember that Page Location is incompatible with the Total revenue metric. So if you have them both in the same report, you will see no data. A customized report could look like this:
If you want to learn how to customize reports, read this article.
However, keep in mind that using Page Location is a high-cardinality dimension which can cause the (other) row to appear.
#6. Landing pages of each subdomain
However, the aforementioned solution is imperfect because of a dimension called Landing Page + query string. Unfortunately, it displays just the page path and query string. The hostname is not included, and you cannot distinguish whether the visitor landed on subdomain1 or subdomain2. Note: Adding Page Hostname as a secondary dimension will not provide consistent results.
In that case, creating a separate landing page report for each subdomain would make sense. Let me show you how that could be done.
In GA4, go to Reports > Library > Create new report > Create detail report > Blank.
In the Dimensions section (on the right sidebar), add the Landing page + query string.
In the Metrics section, add the following:
- Sessions
- Users
- Event count
- Conversions
If you want, you can add more metrics. This is just an example.
Then add the following Report filter: include Hostname and select the subdomain for which you are building this report. Remember, here we are building the Landing page report of the first subdomain now.
Apply changes and save the report. If you are building the report for blog.example.com, then the name of this report could be “Blog’s landing pages”.
Then, repeat the same process for all other subdomains you have.
Finally, go to Reports > Library and edit the report collection (where you want to add those reports). For example, you could edit the Lifecycle collection (if you see it). If not, choose another one.
Then, drag the newly created landing page reports from the right sidebar to the left.
Save changes to the current collection. And that’s it! Now, you see the list of landing page reports on the left sidebar.
Keep in mind that there still is a chance that some landing pages in that report will belong to a different subdomain. It looks like Report filters in GA4 work on the event scope. But the Landing page dimension is session-scoped.
So if a visitor lands on subdomain1 and then goes to subdomain2, the subdomain2‘s landing page report will include the landing page from subdomain1, too (because that was the real landing page of that session).
#7. Seeing subdomain data with comparisons
There is another option if you don’t want to customize/create reports for each subdomain. It’s quicker if you rarely want to check the subdomain landing pages.
Open a standard report where the Landing page + query is the primary dimension. At the top of the report, click Add comparison.
Enter condition: include Hostname (and then select your hostname). Apply changes.
Then click the X next to All users.
Now, this report shows the landing pages of that subdomain. The same caveat (as was mentioned in the previous chapter) still applies – you might see some landing pages from a different domain in the report.
Potential caveat of having multiple subdomains in the same property
Something to keep in mind.
This also applies if you track multiple different domains in the same GA4 property. That caveat is sampling. If you track many websites that are visited by a lot of visitors and generate a lot of events, the probability of reports being sampled will significantly increase.
Subdomain Tracking with Google Analytics 4: Final Words
It looks like we’ve reached the end. Here are the key takeaways from this blog post:
- If you are tracking visitors on different subdomains, but they all belong to the same main domain, you DO NOT need to implement Cross-domain tracking.
- GA4 handles the subdomains of the same domain automatically. Just make sure that you have installed GA4 (with the same measurement ID) on all subdomains.
- Use the same GA property and data stream for all subdomains.
- If you see self-referrals, update the list of unwanted referrals.
Any questions? Is there anything missing? As always, the comment section is at your service.

35 COMMENTS
Hi there! Nice article, I was actually wondering if I have to use the same gym code in every subdomain I'll use.
Hi, that does not matter
Hi Julius,
I have blog website, example.com and a shop subdomain, shop.example.com. Do I need to install same GTM tracking codes on both the sites to subdomain tracking work? As both have different WordPress themes and databases.
Thank you
Yes, as it was already explained in this blog post, you need the same GA tracking ID/code.
Hey, Julius so basically what I am saying is in GTM I created 2 different projects so I have 2 separate sets of header and footer codes.
One set is placed on the main domain & another on the subdomain.
And in Google Analytics also we created two separate accounts for domain & sub domain
What can be done to solve this now?? Any suggestions so that we can attribute the source from the Main domain to subdomain also
The number of GTM accounts and contains does not matter. But you should use one GA property for both domain and subdomain.
Hi Julius, can I update the referral exclusion list also if I haven’t self referral in the traffic acquisition report?
Technically, yes
Our marketing agency is insisting that separating our subdomain WP multisite network into different GA4 properties is "the way Google wants it." In GTM, we're sending one set of events to the GA4 roll-up property and another set of events to dynamic measurement IDs based on the subdomain URL. Other than dealing with all those properties, this seems like an OK approach. When you say you "must" use the same GA4 property for a subdomain network, it makes me wonder if I'm missing something. Should I push back on what our agency is telling me?
If you use the rollup property, then inside that property, the subdomain tracking will still happen. So it's ok
Thank you Julius for your fabulous explanation of things.
Another reluctant here for "must use the same property". Currently we're keeping our blog.mainSite.com.au and mainSite.com.au in two separate properties. But we're obviously missing out on referral information between the two sites- due to G4 automatic omission of self referral. However I'm reluctant to mix the two in one, 1) because I'd like to know how much each site traffics are e.g. overall sessions, users for each site b)it's not ideal to see e.g. all landing page stats mixed in one screen.
What should we do here? How do I keep them separate properties yet understand how people travel between the two? Or really merging them in one property is the only option?
Many Thanks
Use segments, comparisons, audiences to slice your data
You could also have one rollup property and have separate properties for each subdomain. I teach all of that in my GA4 course.
Hi Team! Great article. One quick question - what if I WANT to track self referrals and can't see it? For instance, multiple subdomains are run by different business units and we want to know what impact one has on the other. How do i do the opposite of "ignore unwanted referrals"?
Hi, thanks for the article!
What if I want to track a SaaS product, and each time a customer registers, they get their unique subdomain. For example, our site is domain.com. Then, the subdomains will look like this: customer1.domain.com, customer2.domain.com, etc. Any way to track that? Thanks!
If same GA4 property is installed on all subdomains and you haven't done any customization to GA4 cookies, then this will be handled automatically.
Would it make any difference if the subdomain had a different IP address?
For example, store.mydomain.com could be a store site hosted on a platform server that provides the store building service, so the IP address is going to be different and could be in a different country.
no difference
Hello Julius i hope your doing good! i have a question and i hope you can help me : I have a subdomain blog which linked to the main domain through the main-domain tracking setup to figure the transactions that comes from the blog and measure its performance, however no conversions counted since then on the blog which is weird because there're a huge amount of session and we made alot of transactions as a test to see if any event will count but the result is ZERO. Knowing that i have the same measurement ID for both main domain and subdomain .. and i've used the same measurement ID in GA4 configuration in GTM for both container {Main-Subdomain}.. but the result stills zero.
Btw I have checked the " _ga " and i used the debug to check if the set up was correct.
Thank you Juluis for this valuable information. I have a question regarding subdomains, do I need a separate container in GTM for each subdomain?
Hi Julius, I have used the same data stream for my main and subdomains. However, as you explain in your post about cross-domain tracking, also adjusted the domain configurations.
I changed it to "contains example.com" to cover a.example.com, b.example.com and www.example.com. In the data I now see some with the cross-domain parameter in the url (_gl) and some without. What could be the reason for that some get it and some don't?
As they are subdomains, what should I change the domain configuration to?
Thank you in advance!
Hi Julius, great info as always. I'm tracking a primary domain, to subdomain, to another subdomain, and back to the 1st subdomain. When I remove the 2nd subdomain as a step from my funnel, I can see conversions. If I keep the 2nd subdomain step, I no longer see conversions. All steps are part of the conversion funnel report. After conducting the subdomain value check on all subdomains, I see the same 'name' and 'domains' for all but a slightly different 'value' for the second subdomain. Simply put, there is slight difference towards the end of each value per subdomain:
1st subdomain- GS1.1.1712349755.6.1.1712349926.3.0.0
2nd subdomain- GS1.1.1712349755.6.1.1712349956.58.0.0
Would this warrant establishing a new data stream for the second subdomain? If not, how can I implement all subdomains into a explorer funnel report? Thanks.
What if I don't want to use the same GA4 id on both as one is the marketing site and the other our web app? I just want to track conversion from the marketing site to the web app and then signups
You will have to use the same ID
Thanks for an excellent article!
I have the "opposite" situation: main domain and subdomain are tracked in two separate GA4 Properties.
We'd like to see traffic coming from main to subdomain in the Traffic Acquisiton Report in the subdomain property, but it all ends up as "Direct", there is nothing as "Referral".
While keeping the separate properties as is, would the solution to solve this be to simply actively utm-tag the links from main to subdomain?
I know GA4 is SUPPOSED to handle subdomains of the same domain automatically. But I'm working on a site where users are redirected to a different subdomain than the www. domain during the checkout process. And for this site, GA4 shows a ton of sessions where the reported landing page is that checkout page. This checkout page is not indexed, and there's theoretically no way that it would be the page of entrance for the session. It seems that it's being treated as a separate domain, and a new session is triggered when users go to the checkout page (this seems more likely to me given that, whereas the www. domain is hosted on WordPress, the checkout subdomain is hosted on a clunkier, custom-built CMS with heavy security features). Is there a way to solve this problem?
Difficult to say without an audit of the setup. It sounds like something messing up with the cookies and they are different between the main site and the subdomain after the checkout.
Or maybe something else. But again, difficult to say without troubleshooting.
Hello Julius,
big thanks for all your guides, they helped a lot in my daily work.
I set up subdomain linked tracking in one property over 5 subdomains by using your guide and its working.
Only issue we have now is that the old singular domain properties we were using show more views/events than the combined one while having roughly the same user count. I couldn't find anything searching for this issue, my guess is that the numbers of the singular domain properties might be bloated somehow?
Do you have any pointers in that matter or how i could find out if the numbers are really bloated? The property settings are similar, i triple checked it. Thank you!
Your article has unbalanced paratheses.
However, if the cookies are not present (or are not available for that particular domain (or subdomain), then new _ga and _ga_[measurement_id] cookies will be created.
The lack of having a subdomain included for landing page dimension is the biggest issue I have with GA4, having a large site 30k+ unique page urls across 25+ subdomains where users navigate between multiple subdomains during session makes it really challenging to analyze the data efficiently. At moment I don't have support for BigQuery so I'm reliant on the API and GA4 Reports.
Hi, you could use Page location dimension with "Entrances" metric. However, things like "Key event" attribution to the landing page would not work in such a report
Hi Julius,
Thank you for the great content!
I have a website hosted on the main domain, and a web app on a subdomain.
Currently, GTM (with GA4) is implemented only on the main domain — not on the subdomain.
While following the test in section #3, “Test if your GA4 subdomain tracking works,” I noticed that both cookies are present on the subdomain.
Could you clarify why these cookies appear even though GTM hasn’t been added to the subdomain yet? What does this imply for tracking?
Thank you in advance for your help.
Best regards,
Hi Julius! Thanks so much for this article and all of your great content! It's very helpful and a go-to resource for me.
I'm having an issue where I'm unable to add GTM or GA4 code to a subdomain. I'm having some issues both with the fact that Google is trying to pass the cookies anyway AND I'm concerned that some traffic back from the subdomain to the main domain may be coming in as Unassigned because I can't add the code.
I'm wondering if there's a setting I can use in GA4 or Google Tag Manager to specific that I'd like to treat a certain subdomain (stuff.website.com) as referral / outside traffic, rather than trying to treat it like's associated with the main domain (www.website.com).
Thanks so much for any advice!
I am using a CMP that adds a different CookieID to each subdomain. I am not sure that should be the best way. As when visitor moves from one domain to the other subdomain they are re-asked to consent to cookies, due to the different ID. Between the 3 domains they all share the same GTM and GA4 property.
Shall the Cookie CMP ID be the same accross all subdomains for extra efficiency. Users accepts the cookies once OR all subdomains its a good practice to have a cookie consent for each subdomain?
What is the impact on reporting anyways? Is there any? I guess data loss if a users consents to one domain but then denies consent on the next subdomain?
Thanks for your view on this.
Hey Julius,
You're a Messiah for all of us.
Your guides have been so helpful to me and my colleagues.
We just can't thank you enough.
We're facing one particular issue with sub-domain tracking for my SaaS tool though.
We have one main domain and two sub-domains:
fastrouter.ai
accounts.fastrouter.ai
dashboard.fastrouter.ai
At the moment, we can track which visitors have clicked the CTAs on the homepage and where they came from. But we don't know what happens after they click the CTA. Do they sign up? Do they sign up using GitHub or Google?
At the moment, user authentication is managed by Clerk. So, basically, what's happening is that whenever someone comes from seeing a LinkedIn ad and then clicks on homepage CTA (we can track till here btw) is taken to the Accounts sub-domain (accounts.fastrouter.ai) where the user journey breaks.
What’s happening now (most probably):
1. User clicks CTA (tracked)
2. Taken to Accounts sub-domain → user journey tracking breaks here
3. After sign-up → redirected to Welcome screen (dashboard.fastrouter.ai/welcome)
4. User lands on the dashboard → source shows up as referral/direct
A few words of enlightenment would help us greatly!