6 min read

How to Set Up Real Time Reporting in Google Analytics 4

Real-time reporting in GA4 shows you user activity as it happens — essential when you need to monitor event spikes, campaign performance, or user behavior during launches. Unlike standard reports that update daily, real-time data surfaces within seconds. Here's how to set it up.

Access Real Time Reporting in GA4

Real-time reporting is enabled by default in GA4, but you need to know where to find it and what filters to apply.

Step 1: Open the Real Time Report

In your GA4 property, navigate to Reports > Real Time in the left sidebar. You'll see the Active users card updating every few seconds, along with Top events, Top traffic sources, and Top pages. This view updates in real time as users trigger events on your site.

javascript
// GA4 automatically collects real-time data when gtag.js is installed
// No additional code needed to enable real-time reporting
gtag('event', 'page_view', {
  'page_title': document.title,
  'page_path': window.location.pathname
});
Standard gtag event that feeds into real-time reporting

Step 2: Filter Real Time Data by Dimension

Click Add filter to narrow down what you're seeing. Filter by Event name (e.g., 'purchase'), Page path, Country, or Device category. This isolates traffic from specific campaigns or user segments. For example, filter by Event name = 'signup' to monitor sign-ups in real time during a product launch.

javascript
// Send custom events with parameters that appear in real-time reports
gtag('event', 'purchase', {
  'transaction_id': '12345abc',
  'value': 99.99,
  'currency': 'USD',
  'items': [
    {
      'item_name': 'Pro Plan',
      'item_id': 'SKU-pro-annual',
      'price': 99.99,
      'quantity': 1
    }
  ]
});
E-commerce event with custom parameters for real-time filtering
Watch out: Real-time data only includes events from the last 30 minutes. If no activity occurs in that window, the report shows zero users.

Set Up Real Time Alerts

Alerts notify you when traffic or specific events spike, eliminating the need to constantly check GA4.

Step 1: Create a New Real Time Alert

Go to Admin > Realtime alerts (under your property settings). Click Create alert. Choose a condition such as Active users > 100, Conversion rate drops below 5%, or Event name = 'error'. Set the alert frequency — most teams use Once per day to avoid notification fatigue.

javascript
// Send events with high-value parameters that trigger alerts
gtag('event', 'add_to_cart', {
  'value': 199.99,
  'currency': 'USD',
  'items': [{item_name: 'Premium Subscription'}]
});

gtag('event', 'view_item', {
  'items': [{item_id: 'SKU123', item_category: 'features_demo'}]
});
Track user actions that should trigger real-time alerts

Step 2: Configure Alert Recipients

In the alert settings, select Notification method and choose Email or Slack (if your workspace is connected). Add recipient email addresses or select a Slack channel. Save the alert. Your team will now receive notifications when the condition is met.

javascript
// Alerts are automatic — no code changes needed
// GA4 evaluates conditions on incoming events
gtag('event', 'form_submit', {
  'form_name': 'contact_form',
  'form_destination': '[email protected]',
  'submission_status': 'successful'
});

// This event is evaluated against your alert thresholds in real time
Events automatically feed alert logic — no additional setup
Tip: For launches, set alert thresholds 50% above your normal traffic. This prevents false positives while catching genuine spikes.

Query Real Time Data Programmatically

Access real-time data via the Google Analytics Data API v1 for dashboards, workflows, and automated monitoring.

Step 1: Authenticate with a Service Account

Create a service account in Google Cloud Console. Assign it Editor or Viewer role. Download the JSON key file. In your Node.js or JavaScript environment, initialize the client with this key. This gives you API access without requiring user login.

javascript
const {BetaAnalyticsDataClient} = require('@google-analytics/data');
const path = require('path');

const client = new BetaAnalyticsDataClient({
  keyFilename: path.join(__dirname, 'service-account-key.json')
});

const propertyId = '123456789'; // Your GA4 property ID
Initialize the Google Analytics Data API client with service account credentials

Step 2: Run a Real Time Report Query

Call runRealtimeReport() with your property ID, dimensions (what to group by), and metrics (what to measure). Specify dimension names like eventName, country, pageTitle, and metric names like activeUsers or eventCount. The API returns data from the last 30 minutes.

javascript
async function getRealTimeData() {
  const [response] = await client.runRealtimeReport({
    property: `properties/${propertyId}`,
    dimensions: [
      {name: 'eventName'},
      {name: 'country'}
    ],
    metrics: [
      {name: 'activeUsers'},
      {name: 'eventCount'}
    ]
  });
  
  console.log('Real-time data rows:', response.rows);
  return response;
}

getRealTimeData();
Query active users and event count grouped by event and country

Step 3: Parse Results and Integrate with Monitoring Tools

Loop through the response rows. Each row contains dimension values and metric values. Send the data to your dashboard, Slack, or logging system. Real-time queries are fast because they only cover 30 minutes of data — no complex caching needed.

javascript
const [response] = await client.runRealtimeReport({...});
const rows = response.rows || [];

rows.forEach(row => {
  const eventName = row.dimensionValues[0].value;
  const country = row.dimensionValues[1].value;
  const activeUsers = parseInt(row.metricValues[0].value);
  const eventCount = parseInt(row.metricValues[1].value);
  
  console.log(`${eventName} from ${country}: ${activeUsers} users, ${eventCount} events`);
  
  // Example: Send spike alerts to Slack
  if (eventCount > 100) {
    sendSlackAlert(`Spike: ${eventCount} ${eventName} events from ${country}`);
  }
});

async function sendSlackAlert(message) {
  // Post to your Slack webhook or app
}
Parse real-time rows and integrate with alerting systems
Watch out: Real-time API only covers the last 30 minutes and can't be backfilled. Use standard reports for historical analysis.

Common Pitfalls

  • Real-time data expires after 30 minutes. Queries outside this window return empty results — it's not a historical API.
  • Alerts depend on consistent event tracking. Gaps in your gtag implementation cause alerts to miss spikes.
  • Real-time reports don't include attribution or conversion funnel data — use standard GA4 reports for those insights.
  • Never expose API keys in client-side code. Always use server-side service account authentication.

Wrapping Up

Real-time reporting in GA4 lets you monitor user activity as it happens and respond to campaigns immediately. Start with the UI for monitoring, then add API queries for automated dashboards. If you want to track real-time metrics across multiple 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