Back to Blog
SEO

Google Analytics 4 Setup: A Step-by-Step Guide

How do you set up Google Analytics 4? Data streams and tag installation, conversion events, GDPR-compliant consent and why GA4 never matches Search Console.

Google AnalyticsÖlçümlemeSEOWeb Sitesi

Setting up Google Analytics 4 takes three steps: create a property with a web data stream, install the measurement tag on every page, and define the conversion events that actually matter. Installing the tag is a ten-minute job; the hard part is the third step. Out of the box GA4 tells you how many visitors arrived, but not which page brought you a customer. Below is the full setup, followed by the settings that make the report trustworthy afterwards.

GA4 setup in four steps

The order matters. Leaving the consent mechanism until last makes the first weeks of data unusable.

  • Create a property and a data stream. In analytics.google.com create a property, add a "Web" data stream and enter your site address. The stream gives you a measurement ID starting with G- , which is the value you install.
  • Install the tag. Two options: drop the gtag.js snippet into the head of every page, or install Google Tag Manager and manage the GA4 tag from there. With a single tool, direct installation is enough; if advertising and conversion tags are coming later, Tag Manager saves you a code change every time.
  • Verify that data arrives. The Realtime report and DebugView are the two screens that prove the install works. If both are empty, the tag is either not loading or being blocked by your consent banner.
  • Define conversion events. Form submissions, quote requests, phone and WhatsApp taps, file downloads. Skip this and GA4 gives you a traffic report rather than a business report.

The page-view problem in single-page apps like Next.js

On a classic site every click is a full page load, so GA4 counts page views on its own. In a Next.js or React application, navigation happens on the client: the address bar changes but the page is never reloaded. By default GA4 then sees only the first load and reports a fraction of your real page views. The fix is to listen for route changes and send the event yourself.

// app/analytics.tsx — sends a page view on every route change
  'use client';

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

  declare global {
    interface Window {
      gtag?: (command: string, ...args: unknown[]) => void;
    }
  }

  export function AnalyticsPageView({ measurementId }: { measurementId: string }) {
    const pathname = usePathname();
    const searchParams = useSearchParams();

    useEffect(() => {
      // Bail out quietly if the tag has not loaded or consent was declined.
      if (typeof window.gtag !== 'function') return;

      const query = searchParams.toString();
      const path = query ? pathname + '?' + query : pathname;

      window.gtag('event', 'page_view', {
        page_path: path,
        page_location: window.location.origin + path,
        page_title: document.title,
      });
    }, [pathname, searchParams]);

    return null;
  }

Once this component is in place, turn off the automatic page-view option under enhanced measurement in the data stream settings. If it stays on, every navigation is counted twice and all your session numbers inflate. Whether your site is built this way also matters for performance, which we covered in our guide to building a corporate site with Next.js.

The real work: conversion events

GA4 answers "how many people came" by itself. But that is not the question a corporate site needs answered: which page produces quote requests? For that you have to send the valuable actions as events and mark them as key events in the GA4 interface. For most corporate sites these five are enough:

  • Form submission: the moment the contact or quote form returns a successful response. Measure the server response, not the button click.
  • Phone tap: on mobile traffic this is the most honest conversion there is, and GA4 does not count it automatically.
  • WhatsApp or live chat start: used more than forms in many markets, so it deserves its own event.
  • File download: price lists, catalogues, presentations.
  • Deep engagement on a specific page: time spent on a service or pricing page, the earliest signal of purchase intent.

Send parameters with the events: which form, which page, which service. An event without parameters tells you "10 forms arrived" but never which of them was worth having.

The most common setup mistake is never defining conversion events at all. GA4 then collects data for months while the only output of the report is a visitor count — and no decision can be based on that.

Consent and privacy: the legal half of the install

Analytics cookies are not strictly necessary cookies. That means the measurement tag must not run before the user actively opts in. In practice this ties the GA4 tag to the state of your consent banner: without consent the tag either never loads or runs in a restricted consent mode. Putting a permanent "accept" bar at the bottom of the page while the tag fires from the first millisecond is technically easy and not compliant.

The second point is identifiers: sending personal data such as an email address, a phone number or a name into GA4 as an event parameter breaks both the platform rules and data-protection principles. If you need to distinguish users, use an anonymous identifier you generate yourself. We set out privacy notices, cookie policy and consent management step by step in our guide to a privacy-compliant website.

Why GA4 and Search Console never show the same number

This is the most frequent question after setup, and the answer is not a bug: the two tools measure different things. Search Console counts clicks in search results; GA4 counts a tag running on your site. The gap almost always comes down to one of four causes:

  • Consent: a visitor who declines appears as a click in Search Console and not at all in GA4. Part of your traffic being missing from GA4 is normal.
  • Ad and content blockers: they stop the tag from loading.
  • Loss between the click and the load: if the user goes back before the page renders, Search Console counts it and GA4 does not.
  • Time zone and session definitions: the two tools do not split days and sessions the same way.

The correct use is straightforward: Search Console for search visibility, GA4 for on-site behaviour and conversions. Do not treat one as verification of the other. If your site is not showing up in search at all, we listed the usual causes in why your website is not appearing on Google.

Five reports worth checking after setup

GA4 ships with dozens of reports and most of them are noise for a corporate site. In the first months, five things deserve regular attention: conversions by traffic source, conversion rate by landing page, the device split (if the mobile conversion rate is clearly below desktop, that is an interface problem), the step where visitors drop off most, and the trend of organic traffic over time. If those five are going to become a management dashboard, the method is in our guide to business intelligence and reporting dashboards.

Conclusion

Installing Google Analytics 4 is technically a short job: property, data stream, tag. What makes the install worth anything is defining conversion events properly, running it in step with consent, and never confusing the report with Search Console. Without those three you are left holding a visitor count. If you would like the measurement layer built to fit your existing site, take a look at our web development service or simply request a quote.

Let's Build Your Project

Get a free consultation for your website, mobile app, or corporate software project.

Get a Free QuoteExplore our Web Development service