Event count is how you measure what users actually do in your product. Without proper event tracking, you're blind to feature adoption, drop-off points, and conversion patterns. GA4 makes this straightforward—if you set it up right.
Setting Up Event Tracking
The first step is sending events from your app to GA4. You'll use gtag.js (Google's client-side tracking library) or the Google Analytics SDK.
Step 1: Install gtag.js and configure your Measurement ID
Add the gtag.js snippet to the <head> of your HTML or import it in your JavaScript. You'll need your Measurement ID from GA4 (looks like G-XXXXXXXXXX). This initializes the tracking library.
<!-- Add this to your HTML <head> -->
<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>Step 2: Send custom events when users interact
Call gtag('event', 'event_name', {...}) whenever you want to track an action. GA4 has recommended events like purchase, sign_up, and page_view, but you can send custom event names. Include parameters to add context.
// Track a button click
gtag('event', 'button_click', {
'button_name': 'signup_cta',
'page_section': 'hero'
});
// Track a form submission
gtag('event', 'form_submit', {
'form_name': 'contact_form',
'form_type': 'inquiry'
});
// Track feature usage (custom event)
gtag('event', 'feature_used', {
'feature_name': 'export_to_csv',
'user_plan': 'pro'
});Step 3: Verify events in DebugView
Before you create reports, verify events are reaching GA4. Go to Admin > DebugView in GA4 and open your app. You should see events appear in real time as you trigger them.
// Enable debug mode during development
gtag('config', 'G-XXXXXXXXXX', {
'debug_mode': true
});
// This routes events to DebugView so you can verify immediatelyViewing Event Counts in Reports
Once events are flowing in, GA4 shows you counts and trends in the Events report.
Step 1: Open the Events report
Navigate to Reports > Engagement > Events. This shows all events fired in your property, ranked by event count. You'll see the total number of times each event fired and trends.
// Name events consistently so they aggregate correctly in reports
const trackEvent = (eventName, params = {}) => {
gtag('event', eventName, {
'timestamp': new Date().toISOString(),
...params
});
};
trackEvent('feature_used', { feature_name: 'export' });
trackEvent('feature_used', { feature_name: 'filters' });Step 2: Filter by event name and dimensions
Click any event name to drill down. Add filters (e.g., event count > 50) or segment by device, country, or custom user properties. This shows *who* triggered the event and *how often*.
// Include segmentation data when tracking events
gtag('event', 'conversion', {
'conversion_type': 'signup',
'user_segment': 'trial',
'country': 'US',
'device_category': 'mobile'
});Step 3: Use the Data API to query event counts programmatically
For automated dashboards or real-time monitoring, use the Google Analytics Data API. Install the client library and run a report request to fetch event counts.
const {BetaAnalyticsDataClient} = require('@google-analytics/data');
const analyticsDataClient = new BetaAnalyticsDataClient();
const [response] = await analyticsDataClient.runReport({
property: 'properties/YOUR_GA4_PROPERTY_ID',
dateRanges: [{startDate: '7daysAgo', endDate: 'today'}],
dimensions: [
{name: 'eventName'},
{name: 'date'}
],
metrics: [{name: 'eventCount'}],
orderBys: [
{metric: {metricName: 'eventCount'}, descending: true}
]
});
console.log(response.rows);Common Pitfalls
- Events sent with different parameter names won't aggregate—'button_name' vs 'button_id' creates separate counts. Standardize parameter names before shipping.
- Firing the same event from both client-side and server-side code double-counts. Choose one source of truth (typically client-side with gtag.js).
- GA4 de-duplicates events within a session; very high-frequency events may be sampled if sent faster than ~100 per second from one user.
- Custom events aren't available in reports for 24–48 hours. Use DebugView to verify; wait before troubleshooting missing data.
Wrapping Up
You now have events flowing into GA4 and can track event counts in reports. Monitor the metrics that matter—feature adoption, conversion steps, engagement patterns. If you want to track these same events across tools like Amplitude, Mixpanel, and Stripe simultaneously, Product Analyst can help.