A hostname identifies the domain where your website’s event data comes from when sent to Google Analytics. For example, in the URL https://www.example.com/contact.html
, the hostname is www.example.com
. Google Analytics automatically extracts the hostname from the page_location
event parameter each time you collect an event.
You may need to specify hostnames when setting up a data stream, configuring cross-domain measurement, listing unwanted referrals, or filtering out unwanted events. This article explains the rules for formatting hostnames correctly and identifies the features in Analytics where hostnames are used.
On this page
- Before you begin
- Rules for specifying hostnames
- Where to specify a hostname in Analytics
- Verify which hostnames are sending data
- Troubleshoot hostname issues
Before you begin
To specify a hostname in Analytics:
- You must be an Editor or above at the property level to configure data streams, tag settings, and filters.
- You must have edit access to the relevant container to modify Google Tag Manager settings.
Rules for specifying hostnames
When you specify a hostname in Analytics or in your Google tag settings, the value must follow standard internet hostname conventions. Follow these rules to ensure your hostname is recognized correctly.
Format requirements
- Include the domain and subdomain, but not the protocol or path. A hostname consists of the subdomain, if any, and domain name only. Don’t include
http://,http://, trailing slashes, or page paths.Correct Incorrect www.example.comhttps://www.example.comblog.example.comblog.example.com/articlesexample.comhttp://example.com/ -
Use only permitted characters. Hostnames must not contain spaces, underscores (_), or other special characters. They may contain only the following characters:
- Letters:
athroughz - Digits:
0through9 - Hyphen:
- - Period:
.(used only to separate labels, for example,www.example.com)
- Letters:
- Follow label length limits. The character limit for a hostname is 1000 characters.
- Labels must not begin or end with a hyphen. For example,
my-site.example.comis valid, but-mysite.example.comandmysite-.example.comare not.Note: Hostnames are case-insensitive.www.Example.comandwww.example.comare treated as the same hostname in Analytics.
Common hostname patterns
The following are examples of valid hostnames you might specify in Analytics:
| Hostname | Description |
example.com
|
Root or apex domain |
www.example.com
|
Root domain with www
subdomain |
blog.example.com
|
Subdomain |
shop.example.com
|
Subdomain |
us.store.example.com
|
Nested subdomain |
example.co.uk
|
Country-code top-level domain |
www.example.com
and example.com
are treated as different hostnames in Analytics. If your site is accessible at both, make sure you account for both when specifying hostnames in cross-domain settings, or ensure your site redirects consistently to one version.
Where to specify a hostname in Google Analytics
The following features require you to specify one or more hostnames. Each feature has its own hostname considerations. You can view the linked articles for setup instructions.
Web data streamsWhen you create a web data stream, you enter your website's URL, which includes your primary hostname. For example, example.com
. Analytics uses this to identify your site and generate a measurement ID. The hostname you enter here should be your primary production domain.
The website URL in the data stream is informational and doesn’t restrict which hostnames can send data to your property. Your Google tag will collect data from any page where it’s installed, regardless of the hostname specified in the stream settings.
Learn how to Set up Analytics for a website and/or app to add a data stream.If your users navigate across multiple domains as part of a single journey, for example, from www.example.com
to shop.example.com
, you specify all relevant hostnames in your cross-domain configuration so that Analytics treats the activity as a single session. When entering hostnames for cross-domain measurement, you can use match types such as "contains", "begins with", "ends with", "exactly matches", or "matches RegEx" to define which domains are included.
Enter domain names only without the protocol or any paths. For example, example.com
without https://
. Make sure to include all domains where your Google tag is installed and where users may navigate between during a session.
Learn how to Configure your Google tag settings to manage cross-domain measurement.
If traffic from a specific hostname shouldn't be treated as a referral such as a third-party payment gateway that redirects users back to your site, you can list that hostname in your unwanted referral settings.
Enter domain names only without the protocol or any paths. Common hostnames to list include payment processors, third-party login providers, and booking platforms.
Learn how to Configure your Google tag settings to list unwanted referrals.Google Analytics provides a built-in hostname data filter directly in the Admin interface. You can use this feature to explicitly include or exclude traffic based on the domain, allowing you to easily control which events are collected and processed for your property. You can still use Google Tag Manager alongside it if you need to set up more complex, custom tagging rules for specific hostnames.
When specifying hostnames for filtering, use the same format rules described in this article .
Learn how to Filter out web hostname traffic in Google Analytics .
Verify which hostnames are sending data
You can review the hostnames currently sending data to your property by building a free-form exploration with the following settings:
- Technique: Free form
- Rows: Hostname
- Values: Event count, Total users
- Date range: Last 28 days, or a period relevant to your analysis
Review this report to identify which hostnames are legitimate and which are unexpected. Legitimate hostnames typically include your primary domain, any subdomains you own, and third-party domains you've authorized such as payment processors or booking platforms.
Alternatively, for a quick check, you can change the primary dimension to Hostnamein an existing engagement report to see which domains are sending data without needing to build an exploration from scratch.
page_location
event parameter. Events sent via the Measurement Protocol
that don’t include a page_location
parameter will appear with a hostname of "(not set)".Troubleshoot hostname issues
| Issue | Cause | Solution |
| Hostname shows as "(not set)" | Events sent without a page_location
parameter such as Measurement Protocol or server-side events. |
Ensure all Measurement Protocol payloads include a valid page_location
parameter. |
www.example.com
and example.com
appear as separate hostnames |
Your site is accessible at both versions and doesn't redirect consistently. | Configure your web server to redirect all traffic to a single hostname version, or account for both in your cross-domain settings. |
| Unexpected hostnames appear in reports | Your measurement ID is installed on unauthorized domains, or ghost spam is sending fake hits. | View Filter out web hostname traffic in Google Analytics for steps to exclude this traffic. |
| Staging or development traffic appears in reports | Your Google tag is installed on non-production environments using the same measurement ID. | View Filter out web hostname traffic in Google Analytics for steps to restrict tag firing or filter by hostname. |

