Skip to content
Google Analytics 4 (GA4) — Explained with Examples

Google Analytics 4 (GA4) — Explained with Examples

DodaTech Updated Jun 15, 2026 6 min read

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

TypeExamplesHow They’re Collected
Automatically collectedpage_view, first_visit, session_startNo configuration needed
Enhanced measurementscroll, outbound_click, site_search, video_engagementEnable in GA4 admin (toggle on)
Custom eventsbutton_click, ebook_download, tutorial_completeImplement 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 Create

Step 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

ReportWhat It ShowsKey Metric
Pages and screensMost viewed pagesViews, users, engagement time
EventsAll tracked eventsEvent count, unique users
ConversionsKey actions (purchases, signups)Conversion rate, revenue
User acquisitionHow users found youUsers by first touch channel
Tech detailsBrowser, device, OSUsers 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

MetricDefinitionGood Benchmark
Engagement rate% of sessions with >10s duration60-80%
Average engagement timeAverage time users interact1-3 minutes
Event countTotal events firedDepends on events
ConversionsCompleted key actionsDepends on goal
User retention% returning users20-40%

Common Mistakes

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

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

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

  4. Not filtering internal traffic: Your team’s visits pollute the data. Create a filter in Admin → Data Settings → Data Filters to exclude internal IPs.

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

  1. What is the fundamental difference between UA and GA4 data models?
  2. How do you send a custom event to GA4?
  3. What is enhanced measurement in GA4?
  4. How do you mark an event as a conversion?
  5. Why should you filter internal traffic?

Answers:

  1. UA used session-based tracking (pageviews in sessions). GA4 uses event-based tracking (every interaction is a standalone event with parameters).
  2. Call gtag('event', 'event_name', {param1: 'value1', param2: 'value2'}). All parameters are sent with the event.
  3. Enhanced measurement automatically tracks scrolls, outbound clicks, site search, video engagement, and file downloads without custom code.
  4. In GA4 Admin → Events, find the event and toggle “Mark as conversion” on. This creates a conversion event you can report on.
  5. 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

  1. Create a GA4 property for your site or blog
  2. Install the GA4 tag (via gtag.js or GTM)
  3. Enable enhanced measurement
  4. 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)
  5. Mark tool_download as a conversion
  6. Create a custom report showing tutorial engagement
  7. Set up an internal traffic filter
  8. 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