Google Analytics 4 (GA4) — Explained with Examples
Google Analytics 4 (GA4) is the latest version of Google’s analytics platform, using an event-based data model that tracks user interactions as discrete events rather than pageviews, enabling cross-platform tracking and machine learning-powered insights.
Why GA4 Matters
Universal Analytics (UA) stopped processing data in July 2024. GA4 is now the only Google Analytics option. It shifts from session-based tracking to event-based tracking, giving marketers more flexibility. At DodaTech, GA4 tracks tutorial consumption, tool downloads (Doda Browser, DodaZIP, Durga Antivirus Pro), and user engagement across web and mobile from a single property. Understanding GA4 is essential for any digital marketer in 2026.
GA4 Data Model — Events, Not Pageviews
Think of UA (old) as a photo album — static snapshots of pageviews. GA4 is like a video recording — every click, scroll, and interaction is captured as a moment in time.
graph TD
subgraph GA4[<b>GA4 Data Model</b>]
User[User] --> Session[Session<br/>Time-bound grouping]
Session --> Events[Events<br/>Every interaction]
Events --> AP[Automatically Collected<br/>page_view, session_start, first_visit]
Events --> EP[Enhanced Measurement<br/>scroll, outbound_click, site_search]
Events --> CP[Custom Events<br/>button_click, video_complete]
Events --> CP2[ Conversions<br/>purchase, sign_up]
Events --> UP[User Properties<br/>Logged-in status, plan type]
end
Events --> Reports[Reports & Explorations]
style GA4 fill:#3b82f6,color:#fff
Event Types
| Type | Examples | How They’re Collected |
|---|---|---|
| Automatically collected | page_view, first_visit, session_start | No configuration needed |
| Enhanced measurement | scroll, outbound_click, site_search, video_engagement | Enable in GA4 admin (toggle on) |
| Custom events | button_click, ebook_download, tutorial_complete | Implement with gtag or GTM |
Setting Up GA4 — Step by Step
Step 1: Create a GA4 Property
1. Go to https://analytics.google.com
2. Click Admin → Create Property
3. Enter property name: "DodaTech Tutorials"
4. Select reporting time zone
5. Choose currency
6. Select industry category
7. Click CreateStep 2: Add the GA4 Tag
<!-- Google tag (gtag.js) - GA4 -->
<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 (found in Admin → Data Streams → Your Web Stream).
Step 3: Verify the Tag
// Test that GA4 is firing
console.log('GA4 test: checking dataLayer...');
if (window.dataLayer) {
console.log('dataLayer exists with', dataLayer.length, 'items');
dataLayer.forEach((item, i) => {
if (item[0] === 'config' || item[0] === 'event') {
console.log(` Item ${i}:`, item[0], item[1]);
}
});
}Open Chrome DevTools → Console. You should see GA4 events firing.
Tracking Custom Events
Basic Event Tracking
<button id="download-btn"
onclick="trackDownload('dodabrowser-setup.exe')">
Download Doda Browser
</button>
<script>
function trackDownload(fileName) {
gtag('event', 'file_download', {
'file_name': fileName,
'file_type': 'exe',
'file_size': '45MB'
});
console.log('GA4 event tracked: file_download');
}
</script>Page-Level Event Tracking
<!-- Track tutorial completion -->
<script>
document.addEventListener('DOMContentLoaded', function() {
// Check if user scrolled to 90% of page
const scrollTracker = function() {
const scrollPercent = (window.scrollY + window.innerHeight) /
document.documentElement.scrollHeight;
if (scrollPercent > 0.9 && !window._tutorialComplete) {
window._tutorialComplete = true;
gtag('event', 'tutorial_90_percent', {
'page_title': document.title,
'page_path': window.location.pathname,
'tutorial_category': 'java' // Adjust per page
});
console.log('GA4: Tutorial 90% completion tracked');
}
};
window.addEventListener('scroll', scrollTracker);
});
</script>Google Tag Manager (GTM) Setup
GTM is recommended for non-developers — you manage tags through a UI instead of editing code.
<!-- Google Tag Manager -->
<script>
(function(w,d,s,l,i){
w[l]=w[l]||[];
w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});
var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';
j.async=true;
j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;
f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-XXXXXXX');
</script><!-- GTM noscript fallback (place immediately after <body>) -->
<noscript>
<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-XXXXXXX"
height="0" width="0" style="display:none;visibility:hidden"></iframe>
</noscript>Key Reports in GA4
Engagement Reports
| Report | What It Shows | Key Metric |
|---|---|---|
| Pages and screens | Most viewed pages | Views, users, engagement time |
| Events | All tracked events | Event count, unique users |
| Conversions | Key actions (purchases, signups) | Conversion rate, revenue |
| User acquisition | How users found you | Users by first touch channel |
| Tech details | Browser, device, OS | Users by category |
Creating a Custom Report in GA4
1. Open GA4 → Reports → Library
2. Click "Create new report" → "Create a detail report"
3. Add dimensions: Event name, Page title
4. Add metrics: Event count, Users, Engagement rate
5. Filter: Event name contains "tutorial"
6. Save as "Tutorial Engagement Report"Analyzing User Behavior with GA4
// Track when users search on your site
gtag('event', 'search', {
'search_term': searchInput.value,
'results_count': results.length
});
// Track video engagement
gtag('event', 'video_progress', {
'video_title': 'Java Streams Tutorial',
'video_percent': 50,
'video_duration': 845 // seconds
});
// Track outbound links (to DodaZIP download)
document.querySelectorAll('a[href*="dodazip"]').forEach(link => {
link.addEventListener('click', function(e) {
gtag('event', 'outbound_click', {
'link_url': this.href,
'link_text': this.textContent
});
});
});Conversions — The Metrics That Matter
A conversion is any user action that you define as valuable. In GA4, you mark existing events as conversions.
Setting Up Conversions
1. In GA4, go to Admin → Events
2. Find the event (e.g., 'file_download')
3. Toggle "Mark as conversion" ON// Track a conversion (tool download)
gtag('event', 'download_completed', {
'tool_name': 'Doda Browser',
'version': '3.2.0',
'platform': navigator.platform
});Key GA4 Metrics
| Metric | Definition | Good Benchmark |
|---|---|---|
| Engagement rate | % of sessions with >10s duration | 60-80% |
| Average engagement time | Average time users interact | 1-3 minutes |
| Event count | Total events fired | Depends on events |
| Conversions | Completed key actions | Depends on goal |
| User retention | % returning users | 20-40% |
Common Mistakes
Not migrating from UA before it stopped: UA stopped processing in July 2024. If you haven’t migrated, you have no historical data in GA4. Export UA data before it’s deleted.
Not enabling enhanced measurement: GA4 can automatically track scrolls, outbound clicks, site search, and video engagement — but you must toggle them on in Admin → Data Streams → Enhanced measurement.
Hardcoding measurement IDs: If you track multiple environments (dev, staging, prod) with the same ID, all data mixes. Use environment variables to set different IDs.
Not filtering internal traffic: Your team’s visits pollute the data. Create a filter in Admin → Data Settings → Data Filters to exclude internal IPs.
Forgetting to mark events as conversions: An event is just data until you mark it as a conversion in the GA4 admin. Without this, you can’t track goal completion.
Practice Questions
- What is the fundamental difference between UA and GA4 data models?
- How do you send a custom event to GA4?
- What is enhanced measurement in GA4?
- How do you mark an event as a conversion?
- Why should you filter internal traffic?
Answers:
- UA used session-based tracking (pageviews in sessions). GA4 uses event-based tracking (every interaction is a standalone event with parameters).
- Call
gtag('event', 'event_name', {param1: 'value1', param2: 'value2'}). All parameters are sent with the event. - Enhanced measurement automatically tracks scrolls, outbound clicks, site search, video engagement, and file downloads without custom code.
- In GA4 Admin → Events, find the event and toggle “Mark as conversion” on. This creates a conversion event you can report on.
- Your team’s visits inflate pageviews, engagement time, and conversion rates. Filtering them gives you accurate data about real users.
Mini Project: Set Up GA4 for a Tutorial Site
- Create a GA4 property for your site or blog
- Install the GA4 tag (via gtag.js or GTM)
- Enable enhanced measurement
- Create 3 custom events:
tutorial_start(when user opens a tutorial)code_copy(when user copies a code snippet)tool_download(when user downloads a tool)
- Mark
tool_downloadas a conversion - Create a custom report showing tutorial engagement
- Set up an internal traffic filter
- Verify events fire using GA4 DebugView
This reflects how DodaTech tracks user engagement across hundreds of tutorials to optimize content and improve conversions.
Related topics: API, SEO, Content Marketing, Email Marketing, Social Media Marketing
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro