Sub topic 6
Finding and Understanding the Measurement ID
This chapter assumes you have created a GA4 property and a web data stream. You should also be able to open the stream details in Google Analytics and edit either HTML, a tag manager container, or a CMS integration.
What the measurement ID identifies
A measurement ID identifies a specific GA4 web data stream. It tells the Google tag where to send events collected from a website. A web stream usually has an ID in the form G-XXXXXXXXXX.
The measurement ID belongs to the stream, not directly to your Google account. One GA4 property can contain several streams, such as a production website, a staging website, and an Android app. Each stream has its own identifier and collection settings.
| Identifier | Identifies | Typical format |
|---|---|---|
| Measurement ID | A web data stream | `G-XXXXXXXXXX` |
| Property ID | A GA4 property | A numeric value |
| Stream ID | A data stream in the Analytics interface | A numeric value |
The measurement ID is safe to place in website code. It is not a password or an API credential. Do not confuse it with a Measurement Protocol API secret, which must remain private.
Find the measurement ID
In Google Analytics:
- Open Admin.
- In the Property column, select Data streams.
- Select the web stream for the site you are configuring.
- Copy the Measurement ID from the stream details panel.
Check the website or environment before copying the value. A staging stream and a production stream may have different IDs. Sending both environments to the same stream can pollute reports and make testing harder.
Use the ID in a Google tag
With the gtag.js installation method, replace G-XXXXXXXXXX with the exact value copied from the stream details. Keep the same ID in both locations.
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-XXXXXXXXXX');
</script>Place this code in the page template's <head> section so it can load across the site's pages. If you use Google Tag Manager, enter the measurement ID in the Google tag configuration instead. If you use a CMS integration, paste the ID into the integration's Analytics field. Do not install several independent copies unless you know why each copy is needed.
Confirm that the ID works
Open the site in a private browser window, then go to Reports > Realtime in the same GA4 property. Your visit should appear within a short time. Realtime confirms that data is arriving, but it does not prove that every event is configured correctly.
For detailed testing, enable debug mode temporarily and inspect Admin > DebugView. Debug mode is useful while validating event names and parameters. Remove it or disable it after testing.
gtag('event', 'sign_up', {
method: 'email'
});A missing visitor can indicate an incorrect ID, a blocked script, a consent setting, an ad blocker, or a tag that never loaded. Check the browser's developer tools and the page source before changing the Analytics property.
Exercise
A site uses measurement ID G-AAA1111111 in production, but its staging site sends data with the same ID. What is the main reporting risk?
Show answer
Staging visits and test events will be mixed with production data in the same web stream, which can make production reports inaccurate.