Sub topic 6
Finding and understanding the measurement ID
This chapter assumes you have a GA4 property with a web data stream already created, and that you can read basic HTML and JavaScript. You do not need to have installed the tag yet. Installation is covered in a later chapter. Here the goal is to know exactly what the measurement ID is, where to find it, and how to avoid the mistakes that cause data to go missing.
What the measurement ID is
The measurement ID is the identifier that tells Google Analytics which web data stream should receive the hits your site sends. It looks like G-XXXXXXXXXX: the letter G, a hyphen, and a string of letters and digits, typically ten characters.
Each web data stream has exactly one measurement ID. The ID is not secret. It appears in the page source of every site that uses the tag, so anyone can read it. This has a practical consequence: someone else can copy your ID and send fake events to your stream. The ID identifies a destination. It does not authenticate the sender.
The ID belongs to the stream, not to the property or the account. A property with three streams (for example a website, an iOS app, and an Android app) has three separate identifiers. App streams use a Firebase App ID instead of a G- ID, so the G- format applies only to web streams.
It also helps to separate the measurement ID from two similar-looking identifiers:
| Identifier | Format | Identifies | Used in |
|---|---|---|---|
| Measurement ID | `G-XXXXXXXXXX` | A web data stream | The tag on your pages |
| Property ID | A number, such as `123456789` | A GA4 property | The Admin interface, the Data API, BigQuery export naming |
| Tag Manager container ID | `GTM-XXXXXXX` | A Google Tag Manager container | The Tag Manager snippet |
| Universal Analytics ID | `UA-XXXXXXXX-X` | A legacy Universal Analytics property | Old sites. It no longer collects data. |
Mixing these up is the most common error. Putting a property ID where a measurement ID belongs, or a GTM- ID in a gtag('config', ...) call, produces no data and often no visible error.
Where to find it
The ID lives in the settings of the web data stream.
- Sign in to Google Analytics and open Admin (the gear icon at the bottom left).
- In the Property settings column, choose Data streams.
- Select your web stream from the list.
- The stream details panel shows the Measurement ID in the top right, with a copy button next to it.
The same panel also contains the stream name, the stream URL, and the Enhanced measurement toggle. It also has a View tag instructions link, which opens the install guide with your ID already filled into the snippet.
If the Data streams list is empty, you are probably looking at the wrong property. Use the property selector at the top of the page to check which account and property are active. An account with several properties often leads people to copy an ID from a staging property into the production site.
How the ID travels through the tag
Look at the standard Google tag snippet and notice that the ID appears twice.
<!-- 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>The two occurrences do different jobs.
- The
id=query parameter on the script URL tells Google's servers which tag configuration to download. The file that comes back is the gtag.js library, plus any settings tied to that ID. - The
gtag('config', ...)call tells the loaded library to start collecting for that destination. Without it, the library loads but sends nothing for that stream.
Both values must match. If the URL carries one ID and the config call carries another, the library is loaded for one stream and sends hits to a different one. The result is confusing: Realtime may show activity in a stream you did not expect.
When you see gtag('js', new Date()), that call records the time the library started. It is not related to the ID, and you should leave it as given.
What happens when a hit is sent
After config runs, each page view and event is sent to a Google collection endpoint with the measurement ID attached as a parameter. Google looks the ID up, finds the stream and its property, and applies that property's settings: time zone for the reporting date, data retention, filters, and so on. If the ID does not match any stream, the hit is discarded.
Using the ID in other installation methods
You use the same ID whichever way you install the tag, but where you enter it differs.
- gtag.js directly: paste the snippet from the stream's tag instructions into the
<head>of every page, as shown above. - Google Tag Manager: create a Google tag in your container, enter the measurement ID in the Tag ID field, and trigger it on Initialization - All Pages. The page itself carries only the
GTM-container snippet, so theG-ID never appears in your HTML. - CMS plugin or built-in integration: most platforms ask for the measurement ID in a settings field, often labelled "Measurement ID" or "Google Analytics ID". Paste only the
G-value, without the quotation marks and without surrounding script code.
A plugin that asks for a "Tracking ID" may still expect the G- value for GA4. Check the plugin's documentation, because older plugins were written for UA- IDs and may not support GA4 at all.
Sending the same data to more than one stream
A single page can send data to several destinations. You do this by calling config once for each ID.
<script async src="https://www.googletagmanager.com/gtag/js?id=G-AAAAAAAAAA"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-AAAAAAAAAA');
gtag('config', 'G-BBBBBBBBBB');
</script>Every event on the page is then sent to both streams. This is useful for a roll-up property that combines several sites, alongside a separate property for each site. Be aware of the costs. Each destination counts toward the same property limits independently, and double tagging raises the chance of inconsistent settings. Decide on this structure deliberately, using the planning ideas covered in the chapter on structuring multiple sites.
Common errors
- Copying the ID from the wrong property. Staging and production IDs look alike. Confirm the property name and the stream URL before you paste.
- A typo or a lowercase letter. The ID is case-sensitive in practice. Copy it with the copy button instead of retyping it.
- Using the property ID. A purely numeric value is not a measurement ID.
- Leaving the placeholder. Shipping
G-XXXXXXXXXXproduces no data. Search your templates forXXXXbefore release. - Mismatched IDs in the same snippet. The
id=parameter and theconfigcall must agree, unless you intend to send to two streams. - Duplicate tags. If the page has both a hard-coded gtag snippet and a Tag Manager Google tag using the same ID, each page view can be counted twice. Use one method per ID.
- Deleting and recreating a stream. A new stream gets a new ID. Every site and plugin that used the old one must be updated.
Checking that the ID works
Once the tag is installed, confirm that the ID is routing data to the stream you intend.
- Open your site in a browser.
- In Google Analytics, open Reports and then Realtime.
- Look for your visit within a minute or so.
You can also read the ID from the browser. Open the developer tools, switch to the Network tab, and filter for collect. Each request includes a tid parameter, and its value is the measurement ID being used. If tid is not what you expected, the page is loading the wrong configuration.
The next chapters cover enhanced measurement and verification in more detail. For now, treat a correct ID as the first thing to check whenever a new stream shows no data.
Exercise
A colleague pastes gtag('config', '123456789'); into your site and reports that Realtime shows nothing. What is most likely wrong, and where do you find the correct value?
Show answer
The value is a numeric property ID, not a measurement ID. The tag needs the stream's measurement ID, which starts with G-. Find it in Admin, under Property settings, Data streams, by selecting the web stream. The ID is shown at the top right of the stream details. Also confirm that the script URL's id= parameter uses the same value.
Exercise
A page loads gtag/js?id=G-AAAAAAAAAA but calls gtag('config', 'G-BBBBBBBBBB'). What do you expect to see, and how can you confirm it in the browser?
Show answer
The library is loaded for the first stream but configured to send hits to the second one, so data appears in the stream for G-BBBBBBBBBB (or is lost if that ID is wrong). To confirm, open the Network tab, filter for collect, and read the tid parameter on the requests. It shows which ID receives the hits. Fix it by making both IDs match, unless you deliberately send to two streams.