Sub topic 5
Creating a web data stream
This chapter assumes you already have a Google Analytics account and a GA4 property, and that you can edit your site's page template or use a tag manager. It covers what a web data stream is, how to create one, which settings it holds, and the errors people commonly hit. Finding the measurement ID and installing the tag get fuller treatment in later chapters. Here you only need to know where they fit.
What a web data stream is
A data stream is the source of data inside a GA4 property. The hierarchy is account, then property, then data stream. The property holds your reports and settings. The stream is the pipe that feeds it from one website or app.
A property can contain several streams. Types include web, iOS app, and Android app. A web data stream represents one website, or one set of pages that you want to measure as a single source. Each stream has its own:
- Stream name, a label for you.
- Stream URL, the site's domain.
- Measurement ID, a string such as
G-XXXXXXXXXX. - Enhanced measurement settings.
- Tag settings, such as cross-domain configuration and internal traffic rules.
Nothing is collected until a tag on your pages sends events tagged with the stream's measurement ID. Creating the stream gives you the ID. It does not start collection.
Before you start
Check these items first:
- You are signed in with a Google account that has the Editor role or higher on the property. Viewers and Analysts cannot create streams.
- You know the exact domain you will measure, including whether it uses
www. - You know which property should receive the data. If you have separate production and test environments, decide now whether they share a property. A later chapter covers that structure.
Creating the stream
There are two paths. Which one you see depends on whether the property is new.
From the property setup flow
When you create a new property, the setup wizard ends with a step called "Start collecting data". Choose Web, and the stream form opens.
From Admin
For an existing property:
- Open Admin (the gear icon at the bottom left).
- In the Property column, choose Data collection and modification, then Data streams.
- Select Add stream, then Web.
Filling in the form
The form asks for three things.
| Field | What to enter | Notes |
|---|---|---|
| Website URL | Your domain, such as `example.com` | Enter it without a path. Choose `https://` or `http://` from the dropdown. |
| Stream name | A readable label, such as `Example – Production` | Shown in the Admin and in stream pickers. You can change it later. |
| Enhanced measurement | On by default | Can be switched off or customized later. |
Select Create stream. A panel opens with the stream's details, including the measurement ID and the View tag instructions button.
The URL is mainly a label and a reference for the stream. GA4 does not reject data from other hostnames. Any page that carries your measurement ID sends data to the stream, whatever its domain. This has a practical effect. If someone copies your tag onto another site, or you leave it on a staging server, that traffic lands in your reports. Filtering by hostname in reports, or using separate properties, is how you keep it out.
What the stream page contains
After creation, the stream details page is your control center for that source. These are its main sections:
- Stream details: name, URL, stream ID, and measurement ID.
- Enhanced measurement: a toggle plus a gear icon for individual events.
- Events: modify and create events, and for some setups mark events as key events.
- Google tag: configure tag settings, manage connected tags, and manage domains for cross-domain measurement and internal traffic rules.
Do not confuse the stream ID, a numeric identifier, with the measurement ID, which starts with G-. Tag code uses the measurement ID. The stream ID appears in some URLs and API contexts.
The tag the stream gives you
Selecting View tag instructions shows installation options for gtag.js, Google Tag Manager, or a CMS integration. The standard Google tag for a web stream looks like this. You paste it into the <head> of every page, with your own measurement ID in place of G-XXXXXXXXXX.
<!-- 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 snippet has three parts. The first script element loads the Google tag library asynchronously, so it does not block page rendering. The second creates the dataLayer array and the gtag function that pushes commands onto it. The config command binds the page to your stream, and by default it sends a page_view event.
If you use a CMS plugin or Tag Manager, you will enter only the measurement ID, and the plugin writes the equivalent code for you.
Enhanced measurement at creation time
Enhanced measurement is on when you create the stream. With the tag installed, it collects some events without any extra code. These include page views, scrolls, outbound clicks, site search, video engagement, and file downloads. Form interactions are also available.
Some points matter at the time you create the stream:
- Each event has its own switch, found under the gear icon. Turn off any that you plan to implement yourself, so you do not collect the same interaction twice.
- Site search relies on query parameters. The default parameters include
q,s,search,query, andkeyword. If your site uses another parameter, add it. - Enhanced measurement events appear in reports like any other event. Switching one off stops new data. It does not remove data already collected.
A later chapter covers these events in detail.
Sending an event beyond enhanced measurement
Enhanced measurement does not cover business actions such as signing up. For these, you call gtag yourself. This example sends the recommended sign_up event with a method parameter.
gtag('event', 'sign_up', {
method: 'email'
});Use the recommended event names where one fits, because Google's reports and features expect their names and parameters.
Checking that the stream works
Right after you install the tag, test it. Two quick checks:
- Open the site in a browser and watch Reports > Realtime in GA4. Your visit should appear within a minute or so.
- For event-level detail, turn on debug mode on the config call and open Admin > Data display > DebugView.
<script>
gtag('config', 'G-XXXXXXXXXX', {
'debug_mode': true
});
</script>Remove debug_mode after you finish verifying. Leaving it on sends every visit to DebugView and adds noise to your testing view.
The stream details page also shows a status line. A green check with "Data flowing in the past 48 hours" confirms collection. The status can lag, and it does not appear immediately after installation.
Common errors
| Symptom | Likely cause | Fix |
|---|---|---|
| No data in Realtime | Tag missing from the page, or the wrong measurement ID | View the page source and search for the `G-` ID. Compare it with the stream. |
| Data goes to the wrong property | A copied ID from another stream | Check the ID against **Admin > Data streams** for the intended property. |
| Duplicate page views | The tag is installed twice, for example in the theme and in a plugin | Remove one installation. In Tag Manager, also check that the page does not have a hard-coded tag. |
| Staging traffic in production reports | Same tag on test servers | Use a separate stream or property for testing, or filter by hostname. |
| Ad blocker hides your own visits | Browser extensions block the Google tag script | Test in a clean browser profile. |
| Single-page app records only one page view | Route changes do not reload the page | Enhanced measurement's browser history option normally handles this. Check that it is enabled. |
Several streams and one stream
Create a separate web stream only when you have a reason to. A stream per site is common when you want separate measurement IDs inside one property. Be aware that GA4 reports combine data from all streams in a property by default. You can filter by stream in reports, but users are not stitched across different streams unless you set up cross-domain measurement or use the same stream. For most single-site projects, one web stream is the right start.
Summary of the workflow
- Confirm you have Editor access and know the domain.
- Go to Admin > Data collection and modification > Data streams > Add stream > Web.
- Enter the URL and a clear name, and decide on enhanced measurement.
- Create the stream and copy the measurement ID.
- Install the tag, then verify in Realtime and DebugView.
- Remove
debug_modewhen testing is finished.
Exercise
You created a web data stream and pasted the tag into one page of your site, but Realtime shows no visits. Name three things to check, and explain why the stream's URL field is not one of them.
Show answer
Check that the tag is on the page you are visiting (view source and search for the G- ID), that the measurement ID in the tag matches the one on the stream details page, and that no ad blocker or other browser extension is blocking the Google tag script. The URL field is not a filter. GA4 accepts data from any page that sends events with the stream's measurement ID, so a mismatch between the URL field and the page's domain does not stop collection.
Exercise
Your team has a production site and a staging site, both using the same measurement ID. What problem does this cause, and what are two ways to fix it?
Show answer
Staging visits and events are recorded in the same stream as real users, which inflates traffic and distorts conversion numbers. You can give staging its own stream (or its own property) with a separate measurement ID, or filter reports by hostname so staging is excluded. Separate streams or properties are cleaner because the data is never mixed.