How to Add Google Analytics to Website: The 2026 Install Guide

Add Google Analytics to website in minutes. Step-by-step GA4 install for WordPress, Shopify, Wix, Webflow, and custom HTML. Measurement ID + GTM walkthrough.

How to Add Google Analytics to Website: The 2026 Install Guide

How to Add Google Analytics to Website: The 2026 Install Guide

You created a site. Now you need to know who visits it. Adding Google Analytics to your website is the single fastest way to flip the lights on — and it's free. The 2026 version is Google Analytics 4, and the install boils down to three moving parts: a Google account, a GA4 property with a Measurement ID, and a snippet of code on your site. That's it.

Most guides skip the part that actually trips people up — picking the right install method for your stack. WordPress, Shopify, Wix, Webflow, a hand-coded HTML site, a Next.js app — each one has its own path. Pick the wrong path and you'll spend the afternoon debugging Real-Time reports that never show your visit. We'll walk every option in order.

Worth knowing up front: every step below is reversible. You can swap install methods later. You can delete the property and start fresh. You can move the snippet from <head> to <body> and back. Nothing here is permanent until you're collecting clean data — at which point you'll want to leave it alone. The goal of this guide is to get you to that point fast, without breaking your site.

If you've already got a GA4 property and just need the snippet, jump to Step 2. If you're new to GA4 entirely, start with the prerequisites below — the how to use Google Analytics primer covers what each report does once data starts flowing. And if you're shopping for help, our Google Analytics consultant guide covers fees and what to expect.

Quick reality check before you start: GA4 is forgiving. You won't break anything by clicking around the Admin panel. The worst-case scenario for a botched install is no data — not corrupted data. That makes this a great project to do on a Friday afternoon. Pour coffee. Open Admin. Let's go.

One more thing about scope. This guide focuses on the install itself — getting GA4 to receive your first pageview cleanly. We aren't covering the full reporting layer (that's a different beast), and we aren't covering app SDKs for iOS or Android. Web only. If you need mobile app tracking, you'll add a separate data stream after the web stream is live and wire up the Firebase SDK — outside today's job.

The honest answer about timing: a clean WordPress or Shopify install takes 10 minutes. A custom HTML site with templating takes 20. A Next.js or React app takes 30 to an hour, mostly figuring out where the Script component goes. Plan accordingly. Don't start at 4:55pm on Friday unless you're fine with leaving it half-done over the weekend.

What you'll have at the end of this guide: a working GA4 property tied to your domain, the gtag.js or GTM snippet live on every page, Real-Time confirming visitors are being counted, Enhanced Measurement auto-tracking scrolls and downloads, and at least one conversion event marked. That's the bare-minimum production setup. Anything past that — custom events, audiences, BigQuery exports, server-side tagging — is optimization, not install. Get the basics live first. Optimize later.

Final note on tooling. Keep two browser tabs open through the install: one on analytics.google.com (Admin panel), one on your site. Switch between them constantly. A third tab on tagmanager.google.com if you're going the GTM route. You'll save yourself the frustration of navigating away and losing your place. Bookmark the Data Streams page — it's the page you'll come back to most often once you're collecting data.

How to Add Google Analytics to Website - Google Analytics certification study resource

GA4 Install at a Glance

⏱️10 minAverage install timeWordPress or Shopify
🆔G-XXXXXXXXMeasurement ID format10 chars after G-
🧱100Properties per accountFree tier limit
💰$0Cost of GA4Free forever

Pre-Install Checklist

  • A Google account you can keep long-term (use a company email, not personal Gmail)
  • Admin access to the site you want to track (you'll need to edit code or install a plugin)
  • Your site URL handy, including https:// and www or non-www version
  • Your time zone and reporting currency decided up front (changes wipe historical breakdowns)
  • A privacy policy page live on the site (required by GDPR if you have any EU visitors)
  • An ad blocker disabled in the browser you'll use to verify install

Read this first

The Google account you use to create the property owns the property forever. If that login dies — employee leaves, account locked, password reset disaster — you lose admin access. Use a shared company email like analytics@yourdomain.com. Set up at least two admin users on day one. Future you will say thanks.

Step 1: Create Your GA4 Property

Open analytics.google.com in a fresh tab. Sign in with the company Google account you picked above. Then follow these eight clicks.
👤

Click Admin (bottom-left gear)

GA4 hides setup behind the gear icon. You'll see three columns: Account, Property, Data Stream. If this is your first time, only the Account column will have an entry — your default empty account.
📁

Create Account → name it after your business

Pick the account name carefully — it shows on every report. Use the legal business name, not the website name. Toggle the four data-sharing checkboxes based on your privacy stance. Most marketers leave all four on. Privacy-strict orgs turn them off.
🏷️

Property Name + time zone + currency

Property name should describe the website or app — "Acme Corp Marketing Site" or "Acme Mobile App." Time zone affects when reports start and end each day. Currency is reporting only — doesn't convert your revenue.
🏢

Industry + business size

GA4 uses these to suggest reports and benchmark anonymously. Pick the closest fit — "Internet & Telecom" is a safe default for digital products. Business size is by employee count.
🎯

Select business objectives

Choose 2–3 goals like "Examine user behavior" and "Generate leads." These customize the default report navigation. You can change later under Admin → Reports.
🌐

Web Stream → enter site URL

Click Web, paste your full URL with https://, name the stream (just "Website" is fine), and decide whether to keep Enhanced Measurement on. Keep it on — it's the magic that auto-tracks scrolls, outbound clicks, downloads, and video.
📋

Copy your Measurement ID (G-XXXXXXXX)

After clicking Create Stream, you'll see a panel with the Measurement ID at the top, plus the gtag.js snippet below it. The Measurement ID is what you'll need on every page going forward. Copy it.
💾

Save and exit

GA4 saves automatically. You can close this tab now — your property exists and is waiting for data. Next: get the code onto your site.

Step 2: Pick Your Install Method

Three ways to push the GA4 snippet to your pages. Pick based on your stack and your comfort with code.
📝Direct gtag.js (paste HTML)Full control

Copy the snippet GA4 generates. Paste before the closing </head> tag on every page. Best for: static sites, custom HTML, full control. Worst for: needing to deploy code every time you tweak tracking.

🏷️Google Tag ManagerRecommended

Install one GTM container, then manage every tag (GA4, Meta Pixel, conversion pixels) from a web UI without editing site code. Best for: marketers, agencies, multi-tag stacks. The recommended path for anyone past beginner.

🔌CMS plugin / integrationEasiest

WordPress, Shopify, Wix, Squarespace all have one-click GA4 integrations. Paste the Measurement ID into a settings field — done. Best for: non-technical owners, no-code sites. Worst for: advanced event tracking.

Install Google Analytics on Website - Google Analytics certification study resource

Install by Platform — Click-by-Click for Every Major CMS

Here's where most guides hand-wave. Every platform hides the GA4 setting in a different menu, calls it a different name, and has a different gotcha. Below is the click path for the platforms that cover roughly 95% of websites in 2026.

WordPress (43% of all websites)

Three routes, ranked easiest to hardest. Site Kit by Google — the official Google plugin. Free. Install from the WordPress plugin directory, click Set Up, sign into the same Google account that owns your GA4 property, select the property, done. It also wires up Search Console, AdSense, and PageSpeed in the same flow.

MonsterInsights — the popular third-party plugin. Free tier works for most sites. Premium runs $99–$799/year and adds eCommerce tracking, custom dimensions, and a dashboard widget. Insert Headers and Footers is the leanest option — paste the gtag.js snippet into the Header box. No analytics dashboards inside WordPress, just clean tracking.

Two options. Native integration: Admin → Online Store → Preferences → Google Analytics section → paste your Measurement ID. That's the old way and still works. Customer Events (recommended for 2026): Settings → Customer Events → Add Custom Pixel.

The Customer Events route gives you proper purchase event tracking with revenue, items, and transaction ID — the native integration misses most of that. The Google Analytics website traffic guide breaks down how to read what comes through.

Wix and Squarespace

Wix: Site Dashboard → Marketing & SEO → Marketing Integrations → Google Analytics. Click Connect, sign in with Google, pick your property. Wix handles the snippet injection automatically. Free Wix sites with .wix.com URLs can't add custom analytics — you need a paid plan with your own domain.

Squarespace 7.1: Settings → Advanced → External API Keys → Google Analytics 4. Paste your Measurement ID. Save. Squarespace adds the gtag.js to every page automatically. If you're on a legacy Squarespace 7.0 site, the menu lives under Settings → Advanced → Code Injection — paste the full gtag snippet into the Header box instead.

More Platforms — Quick Install Paths

🌊Webflow

Project Settings → Integrations → Google Analytics → paste Measurement ID → Save Changes → Publish site. Webflow won't push until you click Publish. For GTM, use Custom Code → Head Code instead.

🧩Joomla

Install JCH Optimize or Google Analytics for Joomla extension and paste your Measurement ID. Or open the template's index.php and paste gtag.js inside the head tag. Always backup the template first.

💧Drupal

Install the Google Analytics module from drupal.org/project/google_analytics. Configure at /admin/config/system/google-analytics. Handles role exclusions, path filters, and consent integration out of the box.

📄Static HTMLClassic

Paste gtag.js before the closing head tag on every page. Use a shared header include (PHP, Eleventy partial, Hugo layout, Jekyll _includes) so you paste once, not 200 times.

⚛️React / Next.jsModern

Next.js: drop gtag.js in _app.tsx using next/script with strategy afterInteractive. React: npm install react-ga4, init in root, fire page_view on route changes.

🔄Single Page AppsGotcha

Vue, Angular, and Svelte don't fire pageviews on route change. Hook into router events (Vue afterEach, Angular Router.events, Svelte page store) and manually call gtag for page_view.

Step 3: Google Tag Manager Method (Recommended for Power Users)

If you'll ever run more than one tag — GA4, Meta Pixel, LinkedIn Insight, conversion pixels, custom events — install once via GTM and stop editing site code forever. Create a GTM container at tagmanager.google.com. Paste the GTM snippet (not the GA4 snippet) into your site's <head> and right after the opening <body> — both halves are needed.

Inside GTM, add a new Tag, pick GA4 Configuration, paste your Measurement ID, set the trigger to All Pages. Click Submit, then Publish. Done. From now on, every new tag (heatmaps, A/B tests, ads) gets added inside GTM without touching site code.

One catch worth flagging: GTM and direct gtag.js installed on the same site will fire two pageviews per visit. Pick one. If you migrate from gtag to GTM, remove the original gtag snippet from the site code. The Google Analytics not provided keywords guide explains a related double-counting issue you'll want to avoid.

The other thing GTM unlocks: built-in preview and debug mode. Click Preview inside the GTM workspace, type your site URL, and a debugger window opens alongside the live page. Every tag fire, every variable, every trigger evaluation shows up in the debug panel as you click around. This is how serious tracking gets done — you'd never know your form submit tag wasn't firing without seeing the trigger evaluation fail in debug mode. Direct gtag.js gives you no such window into what's happening.

Worth noting for compliance-heavy sites: GTM also supports server-side tagging. You spin up a GTM container on Google Cloud Run, fire events to your server endpoint, and the server forwards them to GA4. This keeps the user's browser from talking to google-analytics.com directly — better for performance, better for privacy, harder for ad blockers to detect. The setup runs $40–120/month in Cloud Run costs, so it's overkill for small sites. Worth it once you're past 100k monthly users.

Quick Reference: Install Path by Platform

Easiest: Install Site Kit by Google plugin → Set Up → sign in → pick GA4 property → Save.

Lean: Install Insert Headers and Footers → paste gtag.js snippet in Header box → Save.

Premium: Install MonsterInsights → authenticate → pick property → enable eCommerce tracking if needed.

Verify within 24 hours via Real-Time report. WordPress caching plugins (W3 Total Cache, WP Rocket) can delay snippet appearance — clear cache after install.

Add Google Analytics to Website - Google Analytics certification study resource

Direct gtag.js vs Google Tag Manager

Use direct gtag.js
  • +Simplest possible install — paste, save, done
  • +Zero learning curve, no separate UI to manage
  • +Faster page load (one less script to fetch)
  • +Best for static sites, single-tag stacks, dev environments
  • +Easier to debug — view source, see the snippet, confirm Measurement ID
Use Google Tag Manager
  • One container, manage every tag (GA4, Meta, conversions) from one UI
  • Add or change tags without touching site code or deploying
  • Built-in preview/debug mode catches errors before publish
  • Required for any setup with multiple analytics or pixels
  • Industry-standard for agencies, marketers, and growing sites

Step 4: Verify Your Install Actually Works

Install isn't the win. Data is the win. Three ways to confirm GA4 is firing — use all three before you walk away. Method 1: Tag Assistant Companion. Install the Tag Assistant Companion Chrome extension. Visit your site. Click the Tag Assistant icon — you should see a green check for "Google tag (gtag.js)" with your Measurement ID. Red X or missing? The snippet isn't loading.

Method 2: Real-Time report. Open GA4 → Reports → Realtime. Visit your own site in another tab. Within 30 seconds you should see yourself as an active user. Country, browser, device, and page path all populate live. If nothing shows up after two minutes, the snippet isn't reaching GA4.

Method 3: Chrome DevTools Network filter. Open DevTools (F12) → Network tab → filter by "collect." Refresh the page. You should see one or more requests to google-analytics.com/g/collect on every page load. Click one — the Payload tab shows the event name, page path, and your Measurement ID.

If DevTools shows the request, GA4 is receiving it. Standard reports (Acquisition, Engagement, etc.) lag 24–48 hours behind live data on day one. Don't panic if your dashboards are empty the morning after install — Real-Time should be working, and the rest catches up by tomorrow. Worth flagging: if you've got the GA4 DebugView open and aren't seeing events, you also need the Google Analytics Debugger Chrome extension installed and enabled. Without it, debug mode events route to the regular stream and never appear in DebugView.

Step 5: Enable Enhanced Measurement

This is the free magic GA4 ships with that Universal Analytics charged for. Admin → Data Streams → click your web stream → toggle Enhanced Measurement on (if it isn't already). It auto-tracks scrolls past 90% of the page, outbound link clicks, site search (if your URL uses ?q=), embedded video plays/pauses/completes, and file downloads. Zero code required. Click the gear inside Enhanced Measurement to toggle individual sub-features off if you don't want them.

One thing Enhanced Measurement won't do: track form submissions. GA4 has no built-in form_submit event. You'll need to either fire a custom event from your form's onSubmit handler, or use GTM with a Form Submission trigger. Most contact forms render as JavaScript, so the standard GTM form trigger fails — you'll end up firing events on button click or thank-you page load instead. Plan for this upfront.

Step 6: Mark Your Conversions

GA4 collects events automatically (page_view, scroll, click, file_download). You decide which events count as conversions. Admin → Events → toggle the Mark as Conversion switch next to events that matter to your business — purchase, generate_lead, sign_up, contact form submit. Conversions appear in the Conversions report and feed into Google Ads and Search Ads 360 if you've linked them. Most sites mark 3–5 events as conversions — too many and the dashboard gets noisy.

Post-Install Verification Checklist

  • Tag Assistant Companion shows green check for gtag with correct Measurement ID
  • Real-Time report shows your own session when visiting the site
  • Chrome DevTools Network filter "collect" returns requests on every page
  • View source on a live page shows exactly one analytics script block (no duplicates)
  • Data retention is set to 14 months under Admin → Data Settings → Data Retention
  • Enhanced Measurement is on for the web data stream
  • Search Console is linked under Admin → Property Settings → Search Console Links
  • At least one event is marked as Conversion (purchase, generate_lead, or sign_up)
  • Cross-domain tracking is configured if you operate multiple domains
  • Consent Mode v2 is wired up if you serve any EU or California traffic

Admin → Property Settings → Search Console Links → Link. Pick your verified Search Console property. This brings organic search query data into GA4 (when not redacted). For Google Ads, Admin → Property Settings → Google Ads Links → Link. This enables conversion import and remarketing audiences. If you also use BigQuery for advanced analytics, the link is in the same section — free up to 1 GB of export per day. The Google Analytics for SEO guide walks through the Search Console link in detail.

Common Errors and How to Fix Them

No data after 24 hours. First check view source on a live page — is the gtag.js snippet actually there? If a caching plugin stripped it, clear cache. If a security plugin's minifier broke it, exclude analytics from minification. If neither — check the Measurement ID matches between your site code and your Data Stream. One character off, no data.

Duplicate pageviews. You probably have GTM and gtag.js both installed. Remove one. View source — there should be exactly one analytics-related script block. Real-Time works but reports are empty. Reports lag 24–48 hours on a fresh install. Wait. If after three days the reports are still blank, check Admin → Data Settings → Data Retention is set to 14 months, not 2 months.

Ad blockers. Roughly 25% of users run ad blockers in 2026, and most block Google Analytics by default. Your reports will undercount real traffic by 20–30%. This is the universal GA limitation — server-side tracking via the Measurement Protocol is the workaround if you need exact counts. The what is Google Analytics primer covers what you can and can't measure.

Cross-domain tracking missing. If you have multiple domains (example.com and shop.example.com or two separate brand domains), open Admin → Data Streams → your stream → Configure tag settings → Configure your domains → add each domain. Without this, GA4 treats a visitor crossing domains as two separate users.

If you serve EU users, you need Consent Mode v2. Without it, you lose ad personalization and conversion modeling from EU visitors. The fix: install Cookiebot, Iubenda, or OneTrust as your consent management platform (CMP). Connect it to GA4. The CMP fires consent signals (granted or denied) before the gtag.js loads. GA4 then models the missing conversions probabilistically from the consented data. For EU-only sites, this isn't optional — it's required for Google Ads to keep importing conversions.

For US sites worried about California's CPRA, the same setup applies — the CMP just shows different banners depending on the visitor's location. That covers install. The hard part is now done. Spend tomorrow exploring the reports — the Acquisition, Engagement, and Monetization sections cover almost every business question. If you want to go deeper, the Google Analytics course roundup covers the best free and paid training, and the Google data analytics certificate path is worth a look if you're building this into a career.

Google Analytics Questions and Answers

Keep Learning About Google Analytics

About the Author

James R. HargroveJD, LLM

Attorney & Bar Exam Preparation Specialist

Yale Law School

James R. Hargrove is a practicing attorney and legal educator with a Juris Doctor from Yale Law School and an LLM in Constitutional Law. With over a decade of experience coaching bar exam candidates across multiple jurisdictions, he specializes in MBE strategy, state-specific essay preparation, and multistate performance test techniques.