6 min read

How to Track Data Streams in Google Analytics 4

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 StreamsCreate 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.

javascript
<!-- 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>
Replace G-XXXXXXXXXX with your actual measurement ID. This code sends page views and basic events to your data stream.
Watch out: GA4 won't collect data until this code is deployed. If you add it after creating the stream, there's typically a 24-hour delay before you see historical data in reports.

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.

javascript
// 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
  });
}
Use conditional logic to load the correct measurement ID based on your environment. Never send staging data to production.

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.

javascript
// 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'
});
Mobile apps use Firebase Analytics SDK. The SDK connects to your data stream using the Firebase app ID from GA4.

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.

Tip: Use Create property for fundamentally different products (not just environments). For example, separate GA4 properties for your SaaS product vs. your blog. Reserve data streams for the same product across environments or platforms.

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.

javascript
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.com
Debug mode is a development tool only. Check your browser console and Network tab to see what data GA4 is recording.

Step 2: Check Realtime Reports Immediately

Go to ReportsRealtime 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.

javascript
// 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 seconds
Use unique event labels to confirm your data stream is actually receiving your test data.

Step 3: Inspect Events with DebugView

In GA4 AdminDebugView, 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.

javascript
// 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 time
Use a consistent user ID in development to filter DebugView and verify every event being sent.
Watch out: GA4's Realtime report has a 5-10 second latency. If you don't see data immediately, wait a full minute before assuming the stream is broken. Also verify that your tracking code is actually deployed—a syntax error in gtag.js initialization will fail silently.

Common 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.

Track these metrics automatically

Product Analyst connects to your stack and surfaces the insights that matter.

Try Product Analyst — Free