Analytics & Insights11 min read

Google Analytics 4 Complete Setup Guide: 2025 Best Practices

Master Google Analytics 4 with this comprehensive 2025 setup guide. Learn event-based tracking, key events (formerly conversions), eCommerce implementation, and Next.js integration with GDPR-compliant configuration.

Digital Applied Team
October 19, 2025
11 min read

Key Takeaways

  • Event-Based Model Revolution:: GA4 tracks everything as events, providing more flexibility and granularity than Universal Analytics' session-based tracking. Even page views are now events.
  • Key Events Replace Conversions:: Google renamed 'Conversions' to 'Key Events' in 2024. Mark important actions like purchases, form submissions, and downloads as key events to measure business success.
  • Enhanced Google Ads Integration:: Use recommended events whenever possible for better integration with Google Ads and built-in GA4 reports, especially critical for eCommerce tracking.
  • Automatic Event Tracking:: GA4 automatically tracks page views, scrolls, outbound clicks, site searches, video engagement, and file downloads without manual configuration.
  • GDPR Compliance Built-In:: GA4 includes enhanced privacy controls with consent mode, IP anonymization by default, and data deletion capabilities for regulatory compliance.
84%

Market Share: GA4 powers 84% of all analytics installations worldwide

50M+

Over 50 million websites use Google Analytics globally

150+

150+ recommended event types for comprehensive tracking

24-48h

Data processing time for standard GA4 reports

What is Google Analytics 4?

Google Analytics 4 (GA4) is the latest generation of Google's web analytics platform, replacing Universal Analytics which was sunset in July 2023. GA4 represents a fundamental shift in how we track and understand user behavior on websites and mobile apps. At Digital Applied, we help businesses leverage GA4's full potential to make data-driven marketing decisions.

Key Differences from Universal Analytics

  • Event-Based Model: Everything is tracked as an event, providing more flexibility than the session-based model
  • Cross-Platform Tracking: Unified tracking for web and mobile apps in a single property
  • AI-Powered Insights: Machine learning predicts user behavior and identifies trends automatically
  • Privacy-First Design: Built-in privacy controls and compliance with GDPR and other regulations
  • Enhanced Integration: Deeper connection with Google Ads for better attribution
GA4 Adoption in 2025
Universal Analytics was sunset in July 2023, and as of 2025, GA4 is now the standard analytics platform used by millions of websites worldwide. According to BuiltWith, GA4 has achieved widespread adoption with mature documentation and extensive community support.

Setting Up GA4 Property

Creating a GA4 property is straightforward, but proper configuration from the start saves significant troubleshooting later.

Step 1: Create GA4 Property

  • Navigate to Google Analytics and click Admin
  • In the Property column, click Create Property
  • Enter your property name and reporting timezone
  • Select your industry category and business size
  • Choose your business objectives (this customizes your reports)

Step 2: Set Up Data Stream

Data streams are how GA4 receives data from your website or app. For web properties:

  • Select Web as your platform
  • Enter your website URL and stream name
  • Enable enhanced measurement (tracks page views, scrolls, outbound clicks, site search, video engagement, and file downloads automatically)
  • Copy your Measurement ID (format: G-XXXXXXXXXX)

Step 3: Install Tracking Code

You can install GA4 tracking using Google Tag Manager (recommended for flexibility) or directly via gtag.js. For direct implementation, add this to your site's <head>:

<!-- Google tag (gtag.js) -->
<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>

Event Tracking Fundamentals

GA4's event-based model means every interaction is tracked as an event with parameters. Even a simple page view is an event named page_view.

Event Categories

Automatically Collected Events
These events are tracked automatically when you install GA4: page_view, session_start, first_visit, user_engagement, and more. No configuration needed.
Enhanced Measurement Events
When enabled, tracks scroll (90% page scroll), click (outbound links), view_search_results, video_start, video_progress, video_complete, and file_download events.
Recommended Events
Google's predefined events with specific names and parameters: login, sign_up, purchase, add_to_cart, etc. Use these for better Google Ads integration.
Custom Events
Events you create with your own names and parameters. Only use when no recommended event fits your needs.

Tracking Custom Events

To track a custom event, use the gtag function:

// Basic event tracking
gtag('event', 'button_click', {
  'event_category': 'engagement',
  'event_label': 'cta_button',
  'value': 1
});

// Recommended event (login)
gtag('event', 'login', {
  'method': 'Google'
});

Configuring Key Events

In 2024, Google renamed "Conversions" to "Key Events" across GA4. Key events are important actions that measure business success: purchases, form submissions, sign-ups, downloads, etc.

How to Mark Events as Key Events

  • Navigate to Admin in GA4
  • Select Data Display, then Events
  • Find the event you want to mark (it must have been triggered at least once)
  • Toggle the star icon to mark it as a key event
  • Key events appear in conversion reports and Google Ads

Common Key Events to Track

  • eCommerce: purchase, add_to_cart, begin_checkout
  • Lead Generation: generate_lead, form_submit, contact_request
  • Engagement: sign_up, login, file_download
  • Content: video_complete, scroll (90%), content_engagement
Key Events in Google Ads
When you mark events as key events in GA4, they automatically sync to your linked Google Ads account as conversions. This enables conversion tracking, smart bidding optimization, and performance measurement directly in your ad campaigns without additional configuration.

eCommerce Tracking Setup

GA4 eCommerce tracking follows Google's recommended events standard, providing detailed revenue attribution and product performance insights. For businesses running online stores, proper eCommerce tracking is essential to understand customer behavior and optimize conversion rates. Our eCommerce solutions include complete GA4 eCommerce tracking implementation.

Essential eCommerce Events

// View item
gtag('event', 'view_item', {
  currency: 'USD',
  value: 29.99,
  items: [{
    item_id: 'SKU_12345',
    item_name: 'Premium Widget',
    item_category: 'Widgets',
    price: 29.99,
    quantity: 1
  }]
});

// Add to cart
gtag('event', 'add_to_cart', {
  currency: 'USD',
  value: 29.99,
  items: [{
    item_id: 'SKU_12345',
    item_name: 'Premium Widget',
    price: 29.99,
    quantity: 1
  }]
});

// Purchase
gtag('event', 'purchase', {
  transaction_id: 'T_12345',
  value: 29.99,
  tax: 2.40,
  shipping: 5.00,
  currency: 'USD',
  items: [{
    item_id: 'SKU_12345',
    item_name: 'Premium Widget',
    price: 29.99,
    quantity: 1
  }]
});

eCommerce Event Sequence

  • view_item_list: User views product category or search results
  • view_item: User views product detail page
  • add_to_cart: User adds item to shopping cart
  • begin_checkout: User starts checkout process
  • add_payment_info: User enters payment details
  • purchase: Transaction completed successfully

Next.js Integration Example

Implementing GA4 in Next.js requires handling both server and client components. Here's a production-ready setup for Next.js 15. If you need assistance implementing analytics on your website, explore our web development services for expert implementation.

1. Create GA4 Script Component

// lib/analytics.tsx
import Script from 'next/script';

export function GoogleAnalytics() {
  const GA_ID = process.env.NEXT_PUBLIC_GA_ID;

  if (!GA_ID) return null;

  return (
    <>
      <Script
        src={`https://www.googletagmanager.com/gtag/js?id=${GA_ID}`}
        strategy="afterInteractive"
      />
      <Script id="google-analytics" strategy="afterInteractive">
        {`
          window.dataLayer = window.dataLayer || [];
          function gtag(){dataLayer.push(arguments);}
          gtag('js', new Date());
          gtag('config', '${GA_ID}', {
            page_path: window.location.pathname,
          });
        `}
      </Script>
    </>
  );
}

2. Add to Root Layout

// app/layout.tsx
import { GoogleAnalytics } from '@/lib/analytics';

export default function RootLayout({
  children,
}: {
  children: React.ReactNode;
}) {
  return (
    <html lang="en">
      <body>
        {children}
        <GoogleAnalytics />
      </body>
    </html>
  );
}

3. Track Custom Events

// lib/analytics-events.ts
export const trackEvent = (
  eventName: string,
  eventParams?: Record<string, any>
) => {
  if (typeof window !== 'undefined' && window.gtag) {
    window.gtag('event', eventName, eventParams);
  }
};

// Usage in components
import { trackEvent } from '@/lib/analytics-events';

function ContactForm() {
  const handleSubmit = () => {
    trackEvent('generate_lead', {
      form_name: 'contact_form',
      form_location: 'homepage'
    });
  };
}

4. Track Page Views (App Router)

// app/providers.tsx
'use client';

import { usePathname, useSearchParams } from 'next/navigation';
import { useEffect } from 'react';

export function AnalyticsProvider({ children }: { children: React.ReactNode }) {
  const pathname = usePathname();
  const searchParams = useSearchParams();

  useEffect(() => {
    if (pathname && window.gtag) {
      window.gtag('config', process.env.NEXT_PUBLIC_GA_ID!, {
        page_path: pathname + searchParams.toString(),
      });
    }
  }, [pathname, searchParams]);

  return <>{children}</>;
}

Custom Reports and Exploration

GA4's Exploration feature allows you to create custom reports that go beyond standard dashboards, providing deep insights into user behavior.

Popular Exploration Templates

Funnel Exploration
Visualize user drop-off at each step of key processes like checkout, sign-up, or onboarding. Identify where users abandon and optimize those steps.
Path Exploration
See the routes users take through your site. Discover common navigation patterns and unexpected user journeys.
User Lifetime
Analyze revenue and engagement over a user's lifetime. Critical for subscription businesses and SaaS products.

Creating Custom Dimensions

Custom dimensions let you add your own metadata to events for more detailed analysis:

  • Navigate to Admin → Data Display → Custom Definitions
  • Click Create Custom Dimension
  • Name your dimension and select the event parameter it maps to
  • Use in reports to segment data by your custom attributes

GDPR and Privacy Compliance

GA4 includes built-in privacy features, but you still need proper configuration to comply with GDPR, CCPA, and other privacy regulations.

Consent Mode Implementation

Google's Consent Mode allows GA4 to adjust its behavior based on user consent status:

// Set default consent state
gtag('consent', 'default', {
  'analytics_storage': 'denied',
  'ad_storage': 'denied'
});

// Update consent when user accepts
gtag('consent', 'update', {
  'analytics_storage': 'granted',
  'ad_storage': 'granted'
});

Privacy Settings in GA4

  • IP Anonymization: Enabled by default in GA4 (unlike Universal Analytics)
  • Data Retention: Configure how long user data is stored (2-14 months)
  • Signals: Control Google Signals for cross-device tracking
  • Data Deletion: Request deletion of specific user data via User-ID

Recommended Privacy Tools

  • Cookiebot: Comprehensive consent management platform with GA4 integration
  • OneTrust: Enterprise-grade privacy and consent management
  • CookieYes: Affordable GDPR/CCPA compliance solution for small businesses

Need Expert GA4 Implementation & Analysis?

Our analytics specialists will set up GA4 correctly, configure custom events and conversions, create tailored dashboards, and train your team—ensuring you get actionable insights from day one.

Free GA4 audit • Custom dashboard setup • Team training included

Start Tracking What Matters

Google Analytics 4 is now the standard for web analytics, and understanding its event-based model is essential for making data-driven decisions. The shift from Universal Analytics wasn't just a rebrand—it's a fundamental change in how we measure and understand user behavior.

Start with the basics: enable enhanced measurement, set up your key events, and implement recommended events for your business model. As you become comfortable with GA4's interface, explore custom reports and advanced features like predictive metrics and audience building.

Most importantly, ensure your implementation is privacy-compliant from day one. The data you collect is only valuable if it's gathered ethically and legally. With proper setup and configuration, GA4 provides the insights you need to optimize your digital presence and grow your business in 2025 and beyond. For comprehensive digital marketing strategy that leverages analytics insights, explore our full range of digital marketing services.

Frequently Asked Questions