In GA4, data streams are your connection points—each one represents a source of data flowing into your property. Whether you're tracking a website, mobile app, or both, you need to create separate data streams and configure them correctly, or your data won't arrive at all. This guide shows you how to set them up and verify they're working.
Creating Your First Data Stream
Before GA4 can collect data, you need to create a data stream and grab its measurement ID.
Step 1: Navigate to Data Streams in Admin
In GA4, go to Admin (bottom left) → Data Streams → Create new data stream. Choose your stream type: Web, iOS app, or Android app. For web tracking, select Web and enter your domain.
Step 2: Enter Your Website URL and Stream Name
Provide your website URL (include https://) and a descriptive stream name—something like "Production Website" or "Staging Site". GA4 uses this name to identify the stream in reports and admin views.
Step 3: Copy and Deploy Your Measurement ID
GA4 generates a unique measurement ID (format: G-XXXXXXXXXX) for this data stream. Copy it immediately. This ID is what connects your tracking code to this specific data stream.
<!-- Add this to your site's <head> tag -->
<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>Managing Multiple Data Streams and Environments
As your setup grows, separate streams keep your data organized and prevent staging activity from polluting production analytics.
Step 1: Create Separate Streams for Each Environment
In Data Streams, create one stream per environment or platform: "Production Web" (G-PROD123), "Staging Web" (G-STAGING123), "iOS App", and "Android App". Each stream has its own measurement ID or Firebase app ID. Data sent to one stream is completely isolated from others.
// Production environment
gtag('config', 'G-PROD123', {
'page_path': window.location.pathname,
'page_title': document.title
});
// Staging environment (different measurement ID)
if (window.location.hostname === 'staging.example.com') {
gtag('config', 'G-STAGING123', {
'page_path': window.location.pathname
});
}Step 2: Set Up Mobile App Data Streams
For iOS and Android apps, create a data stream by selecting iOS app or Android app in Data Streams. Enter your app's bundle ID (iOS) or package name (Android). GA4 will generate Firebase configuration details—your mobile team uses these to initialize the Firebase Analytics SDK.
// Firebase Analytics setup for mobile apps
import { Analytics } from '@firebase/analytics';
const analytics = Analytics();
// Log a page view event from the app
logEvent(analytics, 'page_view', {
page_title: 'Home Screen',
page_location: 'home'
});Step 3: Review Stream Settings and Custom Events
Click into each data stream to configure Enhanced Measurement (auto-track scrolls, outbound clicks, etc.), set Data Retention, and define User-ID tracking if needed. These settings apply only to that specific data stream.
Verifying Data Flow and Debugging Issues
A configured data stream doesn't guarantee data is arriving. Use these tools to confirm everything is wired correctly.
Step 1: Enable Debug Mode in Your Tracking Code
Add debug_mode: true to your gtag('config') call. This enables verbose logging in your browser's console and shows every request sent to GA4. Debug mode is useful for development but should be disabled before deploying to production.
gtag('config', 'G-XXXXXXXXXX', {
'debug_mode': true
});
// Open the browser console (F12) and look for gtag debug messages
// Also check the Network tab for POST requests to google-analytics.comStep 2: Check Realtime Reports Immediately
Go to Reports → Realtime and load your site in a fresh browser tab. You should see active users and events within 5-10 seconds. If it stays at 0 after 30 seconds, either the measurement ID is wrong or the tracking code isn't deployed yet.
// Send a test event with a unique label to make it easy to spot
gtag('event', 'test_stream_verification', {
'event_category': 'system',
'event_label': 'data_stream_setup',
'timestamp': new Date().toISOString()
});
// Watch for this event in Realtime within secondsStep 3: Inspect Events with DebugView
In GA4 Admin → DebugView, set a filter rule (by user ID or IP address). Visit your site, and you'll see a real-time stream of every event being sent to this data stream, including all parameters. DebugView is the most reliable way to verify data correctness.
// Set a user ID to filter in DebugView
gtag('config', 'G-XXXXXXXXXX', {
'user_id': 'test_user_12345'
});
// Now use DebugView with filter: User ID = test_user_12345
// All events from this user will appear in real timeCommon Pitfalls
- Copying the wrong measurement ID or mixing up production and staging IDs—data either doesn't arrive or lands in the wrong GA4 property
- Deploying the tracking code before testing on a local environment—you deploy first and don't verify until days later, missing early configuration errors
- Creating multiple data streams for the same platform instead of consolidating into one stream—fragments your user journeys and makes cross-session analysis impossible
- Assuming a data stream is working without checking Realtime or DebugView—silent failures happen regularly, and you might not notice missing data for weeks
Wrapping Up
Data streams are the entry point for all GA4 data. Get the measurement ID right, deploy the tracking code, and verify in Realtime or DebugView before moving on. Once confirmed, you can focus on custom events, audiences, and insights. If you want to track and analyze this data automatically across all your analytics tools, Product Analyst can help.