Sub topic 5
Creating a Web Data Stream
This chapter assumes you already have a Google Analytics 4 property, Editor access to it, and access to your website's HTML, tag manager, or CMS integration. A web data stream is the connection between a website and a GA4 property. It receives events from the site, such as page views, clicks, and form submissions.
What a web data stream contains
A property can contain multiple data streams. A website uses a web stream. An Android or iOS app uses an app stream. The stream identifies the source of incoming data and provides the Measurement ID, which is the identifier used by the Google tag.
A web stream usually has these settings:
| Setting | Purpose |
|---|---|
| Stream name | A label that helps people recognize the site |
| Website URL | The site's protocol and domain |
| Enhanced measurement | Automatically collects several common events |
| Measurement ID | Connects the site's tag to this stream |
A property can have separate streams for production, a customer portal, or different brands. Do not create a new stream for every page. One stream normally covers one website.
Create the web stream
- Open the GA4 property.
- Select Admin.
- Under Data collection and modification, select Data streams.
- Select Add stream, then choose Web.
- Enter the website URL and stream name.
- Leave Enhanced measurement enabled unless you have a specific reason to control those events manually.
- Select Create stream.
Use the canonical public URL for the site. Choose https when the site supports it. The URL helps identify the stream, but it does not limit collection to only that exact path.
Understand enhanced measurement
Enhanced measurement is a group of automatically collected events. Depending on the site's behavior and the enabled settings, it can collect page views, scrolls, outbound clicks, site search, video engagement, and file downloads.
Open the stream and select the settings icon in the Enhanced measurement section to review each option. Test the events before relying on them in reports. For example, a site's search query parameter may not match GA4's default configuration, so site search events might need adjustment.
Locate the Measurement ID
Open the web stream details to find the Measurement ID. It has the form G-XXXXXXXXXX. Copy the complete value without spaces. The ID belongs to this stream, so using an ID from another property sends data to the wrong destination.
For a direct gtag.js installation, place the Google tag in the site's page template, usually inside the head element:
<!-- 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>Replace the placeholder with the stream's actual ID. If you use Google Tag Manager, add the ID to a Google tag and publish the container. A CMS integration may ask for the same ID.
Check the stream before continuing
After installation, open Reports > Realtime and visit the site in another browser tab. Your visit should appear within a short time. For detailed testing, enable DebugView collection and inspect the events sent by the site.
Exercise
A website has one production domain and one separate staging domain. Should both use the same web stream?
Show answer
Usually no. Use separate streams or properties when staging data must not mix with production data. At minimum, prevent staging traffic from entering production reports.