Event count is your baseline metric for tracking activity in Google Analytics 4. You need to see it in real-time when you're debugging, and monitor it programmatically when you're running production systems. GA4 gives you visibility at both speeds — through its dashboard and through the Data API.
View Event Count in Real-Time
The fastest way to confirm events are flowing into GA4 is the Real-time report. You'll see data within seconds of user action.
Open the Real-Time Dashboard
In GA4, click Reports in the left sidebar. Under Realtime, select Overview. The Event count card shows events in the last 30 minutes.
// GA4 tracking code — add to <head> tag
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'GA_MEASUREMENT_ID');Break Down by Event Name
Click View by event to see which event types are firing (e.g., page_view, user_engagement, custom events). This confirms your tracking is hitting the right events.
// Send a custom event
gtag('event', 'video_play', {
'video_title': 'Intro to GA4',
'video_id': 'abc123'
});
// This event appears in Real-time within seconds
gtag('event', 'purchase', {
'value': 99.99,
'currency': 'USD',
'transaction_id': 'TX_001'
});Fetch Event Count via the Data API
Build automated monitoring by querying GA4 programmatically. The Data API lets you pull event count data into dashboards, alerts, or custom analysis tools.
Initialize the Data API Client
Install the @google-analytics/data npm package and authenticate with a GCP service account. This gives your app read access to your GA4 property.
const {BetaAnalyticsDataClient} = require('@google-analytics/data');
const analyticsData = new BetaAnalyticsDataClient({
projectId: 'your-gcp-project-id',
keyFilename: 'path/to/service-account-key.json'
});Query Total Event Count
Call runReport() with your GA4 property ID. Request the eventCount metric and set your date range. GA4 returns the total event count for that period.
const response = await analyticsData.runReport({
property: 'properties/GA_PROPERTY_ID',
dateRanges: [{
startDate: '7daysAgo',
endDate: 'today'
}],
metrics: [{
name: 'eventCount'
}]
});
const totalEvents = response[0].rows[0].metricValues[0].value;
console.log(`Total events (last 7 days): ${totalEvents}`);Segment by Event Type
Add the eventName dimension to your query. GA4 breaks down event count by event type and sorts by highest count first. This tells you which events dominate your traffic.
const response = await analyticsData.runReport({
property: 'properties/GA_PROPERTY_ID',
dateRanges: [{
startDate: '30daysAgo',
endDate: 'today'
}],
dimensions: [{
name: 'eventName'
}],
metrics: [{
name: 'eventCount'
}],
orderBys: [{
metric: {name: 'eventCount'},
desc: true
}]
});
response[0].rows.forEach(row => {
const eventName = row.dimensionValues[0].value;
const count = row.metricValues[0].value;
console.log(`${eventName}: ${count}`);
});Detect Event Count Anomalies
A sudden drop in event count usually means a tracking bug. Set up automated checks to flag abnormal days.
Compare Daily Event Count to Baseline
Fetch daily event counts for the last 30 days. Calculate the average, then flag any day that falls below 70% of the baseline. This catches tracking issues quickly.
const response = await analyticsData.runReport({
property: 'properties/GA_PROPERTY_ID',
dateRanges: [{
startDate: '30daysAgo',
endDate: 'today'
}],
dimensions: [{
name: 'date'
}],
metrics: [{
name: 'eventCount'
}]
});
const dailyCounts = response[0].rows.map(row => ({
date: row.dimensionValues[0].value,
count: parseInt(row.metricValues[0].value)
}));
const avg = dailyCounts.reduce((sum, d) => sum + d.count, 0) / dailyCounts.length;
const threshold = avg * 0.7;
dailyCounts.forEach(day => {
if (day.count < threshold) {
console.warn(`⚠️ ${day.date}: ${day.count} events (below threshold of ${threshold})`);
}
});Common Pitfalls
- Mixing up
eventCount(total events fired) witheventCountPerUseroreventsPerSession— they're different metrics and tell different stories - Forgetting the 24-hour delay in the Data API — if you check at 10am and see no events from yesterday, that's normal; wait until after 2pm UTC
- Not checking Event count per session when overall count drops — you might have fewer sessions but more events per session, which is actually healthy growth
- Ignoring duplicate tracking — a spike in event count might be caused by event firing twice per action, not by actual user growth
Wrapping Up
Monitoring event count in GA4 is non-negotiable for production tracking. Use the Real-time report for instant feedback when you're debugging, and the Data API for automated monitoring of trends. If you want to track this automatically across tools, Product Analyst can help.