How to Set Up Google Analytics (GA4): The Complete Step-by-Step Guide
Learn how to set up Google Analytics 4 step by step: create your stream, install the tag, test events in DebugView, and set 14-month retention.
Most guides on how to set up Google Analytics end the second you paste a snippet into your <head>. From a backend perspective, that’s like plugging in a logging pipeline and never checking whether the server is dropping half the requests or writing every row twice.
Google Analytics 4 (GA4) measures what happens after someone lands on your website: which pages they open, how long they stay engaged, and which actions convert. It doesn’t tell you how Googlebot crawls your domain or which search queries triggered your snippet (that belongs to Search Console, which I covered in my step-by-step Google Search Console setup guide).
I came into SEO from backend engineering, not marketing, so I treat analytics as a measurement system first. An approximate number isn’t data. Below is the exact setup order I follow so GA4 collects clean events from day one instead of leaving you with broken charts three months later.
What Google Analytics 4 measures (and why default settings aren’t enough)
Google Analytics 4 is Google’s free, event-based analytics platform for websites and apps that records every page load, scroll, click, and conversion as a structured event. Out of the box, however, GA4 ships with a two-month granular data retention window and zero internal traffic filtering, so relying on default settings means building reports on noisy, short-lived data.
Unlike the retired Universal Analytics (which stopped processing standard data on July 1, 2023), GA4 doesn’t split site activity into separate “hit types” and “views.” Everything is an event attached to a user and a session, fed into your property through a data stream.
Once configured cleanly, GA4 gives you reliable visibility over four core areas:
- Traffic acquisition: which channels (organic search, direct, referral, email, paid) bring sessions and which ones actually convert.
- Page-level engagement: which URLs attract visits, hold attention, and trigger downstream actions.
- Key events: the specific business outcomes (form submissions, signups, bookings, checkouts) that separate useful traffic from vanity page views.
- Device and geography splits: whether your real audience visits mostly on mobile or desktop, and from which countries or cities. That split is also the first number I check before choosing desktop or mobile tracking when creating your first TrueRanker project.
Just don’t assume Google’s defaults match what your reporting needs. Default GA4 settings drop history fast.
How to create your Google Analytics 4 account, property, and web data stream
Creating a GA4 property takes four linear steps inside Google Analytics: opening an account under a company-owned Google login, configuring your property’s reporting time zone and currency, picking baseline business objectives, and generating a web data stream with a G- Measurement ID.
Here are the four setup screens in order, including the small defaults that trip people up later.
Step 1: Create your Google Analytics account under a permanent business login
Go to Google Analytics and sign in with a permanent company Google account, never a personal Gmail or an external contractor’s email. Losing root admin access when someone leaves a project is a completely avoidable headache.
- Click “Start measuring” (or open
Admin > + Create > Accountif you already manage other properties). - Enter an Account name, usually your company or brand name.
- Review the “Account Data Sharing Settings” checkboxes and leave only the options your privacy policy permits.
- Click Next.
Step 2: Set up your GA4 property, time zone, and currency
A GA4 property is the container that stores measurement data for one website or product, and its time zone and currency control how daily rollups and revenue totals are calculated across every report.
- Enter a clear Property name (for example, your domain or brand name).
- Select your primary Reporting time zone so midnight cutoffs don’t split a day’s conversions across two dates.
- Select the Currency your site transacts or reports in.
- Click Next.
Step 3: Choose business details and reporting objectives
Your business details and objectives only customize which default report cards appear in GA4’s left navigation; they don’t change what data GA4 collects under the hood.
- Pick the closest Industry category and Business size, then click Next.
- On the “Choose your business objectives” screen, select “Get baseline reports”. Picking individual goals hides standard lifecycle reports from the sidebar until you re-add them manually, which only slows you down during initial setup.
- Click Create, pick your country, and accept the Google Analytics Terms of Service (plus the GDPR Data Processing Terms if you have visitors in the EEA or UK).
Step 4: Create a web data stream and review Enhanced Measurement
A web data stream connects your website domain to your GA4 property and generates your G- Measurement ID, while Enhanced Measurement automatically tracks seven common user interactions without custom JavaScript.
- On the “Start collecting data” screen, select Web.
- Enter your website URL (leave
https://selected and type the exact canonical host, with or withoutwww) and give the stream a clear Stream name. - Leave Enhanced measurement turned on. By default, it tracks
page_view,scroll(at 90% depth), outboundclick,view_search_results(site search),video_start/video_progress/video_complete,file_download, andform_start/form_submit. - Click the gear icon next to Enhanced measurement if you want to disable noisy events right away (for example, automatic form interactions can fire false positives on embedded search bars or third-party widgets).
- Click Create stream.
On the Web stream details screen, copy your Measurement ID (it starts with G-). You’ll need it for the installation step below. Keep one clean stream per website.
How to install Google Analytics 4 on your website (3 methods compared)
You can install GA4 on a website in three ways: through a CMS integration or WordPress plugin, through Google Tag Manager (GTM), or by pasting the native gtag.js snippet directly into your site’s <head>. Pick one method and stick to it; running a plugin and a GTM tag for the same Measurement ID doubles every page view and ruins your engagement rate.
Here’s how the three options compare before you choose:
| Installation method | Best for | What you need | Main risk |
|---|---|---|---|
| CMS integration or plugin | WordPress, Shopify, Wix, Squarespace, Webflow | Your G- Measurement ID |
Plugin conflicts or accidentally leaving a second tag active |
| Google Tag Manager (GTM) | Marketing teams adding custom events or multiple tags | Active GTM container plus your G- Measurement ID |
Forgetting to click Publish after testing in Preview |
Manual gtag.js snippet |
Custom sites, Astro, Next.js, lightweight setups | Global <head> template access |
Theme updates overwriting the snippet if edited carelessly |
Method 1: Install GA4 with a CMS integration or WordPress plugin
If your site runs on a major CMS or store builder, pasting your G- Measurement ID into its native analytics field or Google’s official Site Kit plugin is the quickest way to deploy GA4 without editing template files.
- WordPress: install Site Kit by Google from
Plugins > Add New, activate it, sign in with the same Google account that owns your GA4 property, and select your Account, Property, and Web data stream. Site Kit inserts the Google tag across every page automatically. - Shopify: open the Google & YouTube channel app in your Shopify admin, connect your Google account, and select your GA4 property so purchase and checkout events pass cleanly.
- Squarespace, Wix, or Webflow: open your site’s Integrations or External API Keys settings, paste your
G-Measurement ID into the Google Analytics field, save, and republish your site.
Method 2: Install GA4 with Google Tag Manager (recommended for marketing teams)
Google Tag Manager lets you deploy GA4 through a single Google Tag triggered on Initialization - All Pages, and later add custom button clicks, scroll thresholds, or ad pixels without waiting for a code deploy.
- Open Google Tag Manager and select the container already installed on your site.
- In the left menu, go to
Tags > Newand name the tag clearly (for example,GA4 - Google Tag). - Click Tag Configuration and select “Google Tag”. Don’t hunt for the older “GA4 Configuration” tag name you might still see in outdated tutorials; Google replaced it with Google Tag.
- Paste your
G-Measurement ID into the Tag ID field. - Click Triggering and choose
Initialization - All Pagesso the Google Tag initializes before any other event tags try to fire. - Click Save.
Don’t skip testing yet, and don’t forget to hit Submit > Publish in GTM once your test passes. Leaving a working tag stuck in an unpublished workspace is one of the most common reasons a “completed” setup collects zero sessions.
Method 3: Install the Google tag (gtag.js) manually in your HTML
For custom-built sites, static frameworks like Astro or Next.js, or teams that want zero extra tag-manager overhead, paste the gtag.js snippet directly after the opening <head> tag in your shared layout template.
- In GA4, go to
Admin > Data collection and modification > Data streams, click your web stream, and open “View tag instructions”. - Switch to the “Install manually” tab and copy the full JavaScript snippet.
- Paste it immediately after the opening
<head>tag in the global layout file that renders on every page (not only your homepage). - Deploy your site and clear any server or CDN cache.
Whichever method you pick, check your rendered page source afterwards to confirm only one G- tag loads. One tag per site, never two.
How to verify that Google Analytics 4 is actually collecting clean data
A saved tag isn’t a working tag; before you close your browser, confirm that events leave your site, land inside GA4’s DebugView and Realtime reports, and fire exactly once per page load.
Skipping verification is where bad setups hide for months. GA4 doesn’t email you when a tag silently fails or fires twice.
Test live events in GA4 DebugView (not just GTM Preview)
GTM Preview only proves your browser fired a tag, whereas GA4 DebugView proves Google Analytics actually received the event and parsed its parameters. Treating GTM Preview alone as a verified GA4 setup is mixing apples and oranges; you need to confirm receipt on the GA4 side too.
- If you used Google Tag Manager, click “Preview” in GTM, enter your site URL, and connect Tag Assistant. Having Preview mode active automatically enables GA4 debug mode for your session.
- If you used a CMS plugin or manual
gtag.js, install the official Google Analytics Debugger Chrome extension, turn its icon ON, and reload your website. - In GA4, open
Admin > Data display > DebugView. - Select your device from the top-left Debug device dropdown and click through two or three pages on your site.
- Confirm
page_view(andsession_start/first_visiton a fresh session) appear on the blue timeline, then click an event to inspect itspage_locationandpage_titleparameters.
Confirm your visit in Realtime and check for double-counted page views
Once DebugView looks right (and after you click Submit > Publish in GTM if you used Method 2), open Reports > Realtime in GA4 and browse two pages of your site in a normal tab.
Watch the Event count by Event name card closely. Load one single page and check whether page_view increments by 1 or by 2. If it jumps by 2 on every load, you have duplicate tags running (typically a WordPress plugin plus a GTM tag, or a hardcoded snippet left in header.php after moving to GTM). Fix that immediately before real traffic accumulates.
Troubleshooting when GA4 shows zero data on day one
If DebugView and Realtime stay completely empty after five minutes, check these four causes in order before touching your property settings:
- Cookie consent banner blocking execution: if your site uses a CMP or Consent Mode banner and you haven’t clicked Accept in your test browser, analytics cookies (and sometimes the full tag, depending on implementation) won’t fire normally. Test after accepting analytics cookies and verify your banner’s firing rules.
- Browser ad blockers or privacy browsers: Brave, Firefox Enhanced Tracking Protection, uBlock Origin, and similar extensions block
googletagmanager.comandgoogle-analytics.comlocally. Test in a clean Chrome profile without blockers. - Stale server or CDN cache: WordPress caching plugins and CDNs like Cloudflare can serve pre-edit HTML without your new snippet. Purge the cache and inspect the live page source (
Ctrl+U) for yourG-ID. - Unpublished GTM container or wrong Measurement ID: verify your GTM workspace shows a published live version and double-check that you didn’t copy the Stream ID (digits only) instead of the
G-Measurement ID.
Never trust an untested tracking tag.
Five mandatory post-setup settings before you trust any GA4 report
Installing the tag only starts raw collection; five quick settings inside GA4 Admin decide whether you keep more than two months of exploratory data, avoid inflating numbers with your own team, and connect organic search queries cleanly.
Here’s the day-one checklist I run on every new property before anyone opens a report:
| Setting | Where in GA4 Admin | Default | Set it to | Why it matters |
|---|---|---|---|---|
| Event data retention | Data collection and modification > Data retention |
2 months | 14 months | Keeps user- and event-level data available in Explorations |
| Internal traffic filter | Data streams > Configure tag settings + Data filters |
Inactive / none | Office & team IPs excluded (Active) | Stops internal testing from inflating sessions and skewing conversion rates |
| Key events | Data display > Events / Key events |
None | 2 to 4 real business actions | Separates pages that bring traffic from pages that convert |
| Search Console link | Product links > Search Console links |
Unlinked | Connected to verified GSC property | Brings organic queries and landing-page clicks into GA4 |
| User permissions | Property access management |
Creator only | Role-based (Admin / Editor / Viewer) | Lets teammates and agencies work without sharing your Google password |
Extend event data retention from 2 months to 14 months
GA4’s standard aggregate reports keep historical summaries, but granular event-level data used in custom Explorations expires after just 2 months unless you change it manually (as documented in Google’s GA4 data retention documentation).
- Open
Admin > Data collection and modification > Data retention. - Change “Event data retention” from
2 monthsto14 months. - Leave “Reset user data on new activity” turned ON if you want returning users’ timers to refresh, then click Save.
If you need raw event history beyond 14 months, link GA4 to BigQuery under Admin > Product links > BigQuery links (the free sandbox covers small and mid-sized sites comfortably).
Filter out internal traffic from your team and office IPs
On a new or low-traffic website, developers and marketers checking staging URLs and landing pages all week can easily distort your session counts and wreck your real conversion rate.
- Go to
Admin > Data collection and modification > Data streams, click your web stream, then openConfigure tag settings > Show more > Define internal traffic. - Click Create, name the rule (for example,
Office and Remote Team), keeptraffic_typeset tointernal, and enter your static office IP address or CIDR range. Save the rule. - Now activate the filter: go to
Admin > Data collection and modification > Data filters, click the built-in “Internal Traffic” filter, switch its state from Testing to Active, and click Save.
That second step is where people trip up. Defining the IP rule alone only tags your visits; switching the filter from Testing to Active is what actually removes them from your reports.
Mark 2 to 4 real business actions as key events
In GA4, a key event is the current name for what earlier GA4 docs called a conversion: an event you flag as a meaningful business outcome. An account without key events tells you people arrived, but gives you zero proof that your pages did their job.
Go to Admin > Data display > Events (once events start appearing after 24 to 48 hours) or Admin > Data display > Key events > New key event, and mark only the 2 to 4 actions that actually matter:
- SaaS or service site: account signup, demo booking, or contact form submission (
generate_lead). - E-commerce store:
purchaseandbegin_checkout. - Publisher or content site: newsletter signup or gated resource download.
Keep the list tight. Marking button hovers or 50% scroll depth as key events turns your conversion column into noise.
Link Google Analytics 4 with Google Search Console
Linking GA4 to your verified Search Console property pulls organic search queries, impressions, clicks, and average positions straight into GA4 so you can inspect pre-click demand next to post-click engagement.
- Make sure you already verified your domain in Search Console (follow my Google Search Console setup guide first if you haven’t) using the same Google account that has Editor or Administrator rights in GA4.
- In GA4, go to
Admin > Product links > Search Console linksand click Link. - Click “Choose accounts”, select your verified Search Console property, then pick your GA4 web data stream and click Submit.
- To make the two new Search Console reports visible in your left sidebar, open
Reports > Library, locate the Search Console collection card, click the three-dot menu, and select Publish.
Set up user permissions without sharing your Google password
Never hand out your primary Google credentials to an agency, developer, or client. Manage access strictly through Admin > Property access management (or Account access management if they need access to all properties):
- Administrator: full control, including user management and deleting properties. Reserve this for founders and permanent internal owners.
- Editor: can configure events, key events, filters, and product links, but can’t manage users. Ideal for marketers and analytics specialists.
- Analyst or Viewer: read-only reporting (plus custom Explorations for Analysts). Ideal for clients and stakeholders.
Fix retention and filters on day one.
What Google Analytics doesn’t tell you about SEO (and how to complete the picture)
Google Analytics tells you what visitors did after clicking your link, but it can’t show exact daily keyword rankings by city and device, gives you zero visibility into what competitors are ranking for, and misses zero-click mentions in AI search completely.
If you try to run SEO strictly from GA4, you’re looking at the bottom half of the funnel with the top half blacked out. Three blind spots show up fast:
- No localized daily rankings: GA4 shows organic sessions by landing page, and even after linking Search Console you only get delayed, blended averages. As I broke down when explaining why Google rankings shift by location and device, an averaged position hides whether you’re winning page one on mobile in New York or sitting on page two in London.
- No competitor tracking: GA4 only sees traffic that reaches your own server. It can’t tell you which rival took your top spot this morning or which keywords competitors are gaining ground on.
- Blindness to zero-click AI search: if ChatGPT, Gemini, Claude, or Perplexity recommends a competitor instead of your brand, or mentions your brand without a clickable citation link, GA4 records zero sessions. You only see the small fraction of AI answers that actually generate a referral click.
To close that loop cleanly, pair GA4 with Search Console and TrueRanker. Use GA4 for post-click engagement and key events, track exact keyword positions by city and device in TrueRanker’s daily local rank tracker, and monitor whether LLMs mention or cite your URLs in TrueRanker’s AI visibility tracker.
When you need every metric in a single client dashboard without copying screenshots every week, combine your GA4 property with TrueRanker’s free Looker Studio connector (setup takes three steps in the docs on connecting TrueRanker to Looker Studio), or schedule recurring client deliverables with TrueRanker’s automated SEO reports.
Pair post-click analytics with real rank tracking.
Frequently asked questions about setting up Google Analytics
How long does it take for Google Analytics 4 to show data?
Realtime and DebugView display live events within seconds to a few minutes after your tag is installed and published. Standard GA4 reports (Acquisition, Engagement, and linked Search Console tables) typically take 24 to 48 hours to process and populate your first full day of data.
Is Google Analytics 4 completely free?
Yes, standard Google Analytics 4 is completely free for websites and mobile apps, with no subscription fee required for property setup, Enhanced Measurement, DebugView, or linking Google Search Console. Google Analytics 360 is a separate paid enterprise tier built only for high-volume organizations that need higher sampling limits and formal SLAs.
Do I need both Google Analytics and Google Search Console?
Yes, because they measure opposite halves of the search journey. Google Search Console tracks pre-click visibility and site health (impressions, queries, click-through rate, crawl errors, and indexation), while Google Analytics tracks post-click user behavior, engagement, and key events once visitors land on your pages.
Should I install GA4 directly with gtag.js or through Google Tag Manager?
Use Google Tag Manager if you expect to track custom button clicks, form events, consent rules, or ad pixels without editing website code every time. Use direct gtag.js or a native CMS integration if you run a lightweight site and only need standard GA4 page views and Enhanced Measurement.
What happens if I accidentally install GA4 twice (plugin plus GTM)?
Running two tags that point to the same G- Measurement ID fires duplicate page_view and engagement events on every page load. That doubles your reported views, artificially lowers bounce rates, and corrupts trend comparisons until you remove one of the two installations and verify single-event firing in Realtime or DebugView.





See what happens before visitors land in GA4
Google Analytics starts counting once someone clicks your link. Pair it with TrueRanker to track daily local rankings, monitor competitors, and measure brand citations across AI search engines.
Written by

Sergio Pérez
Co-Founder, Lead Backend & Infrastructure
Sergio co-founded TrueRanker and owns the backend those rankings run on: servers, security, uptime, and the data logic behind rank tracking, backlink monitoring and AI-visibility checks. He writes about technical SEO, 404s, content clusters, crawl health, because that is the layer he builds, not a topic he borrowed. If a position, a link or a citation is late or wrong, it is his stack that has to answer.
You might be interested
Rank Tracker Not Matching Google? Why Both Numbers Are Real
Rank tracker not matching Google? See the six variables that split the two numbers, why incognito doesn't fix it, and how to check your real position.
Sergio Pérez13 min read
Read the postHow to write SEO reports for clients they'll actually read
What belongs in SEO reports for clients, which metrics earn a place, and how to write one, with a real sample of rankings, links and AI visibility.
Javier Quevedo9 min read
Read the postAutomated SEO Reporting: Stop Wasting Non-Billable Hours [2027]
Stop wasting non-billable hours. Create automated, white-label SEO reports with custom charts and Google Search Console data using TrueRanker.
Javier Quevedo3 min read
Read the postDiscover the position in Google of your website’s keywords
Want to know where your website ranks on Google? Learn why Incognito mode lies and 3 accurate ways to check your real keyword positions for free.
Javier Quevedo5 min read
Read the post