How to Add Google Analytics (GA4) to a Website

Quick answer

To add Google Analytics to a website, create a Google Analytics 4 property, add a web data stream, and copy its measurement ID (starting G-). Install the Google tag by pasting the code into your site's head, entering the ID in your website builder, or using Google Tag Manager. Confirm it works in the Realtime report.

What you need before you start

  • A Google account
  • Access to your website’s admin area or code
  • About 15 minutes

Google Analytics 4 (GA4) is the current version of Google Analytics. Older Universal Analytics properties have been retired, so any guide that mentions a tracking ID starting with “UA-” is out of date. In GA4 you will use a measurement ID that starts with G-.

Step 1: Create a Google Analytics account and property

  1. Go to the Google Analytics website and sign in.
  2. Click Start measuring (or, if you already have an account, open Admin and click Create, then Property).
  3. Enter an account name, such as your business name, and choose your data-sharing settings.
  4. Enter a property name, your reporting time zone and your currency.
  5. Fill in the business details and objectives, then accept the terms of service.

An account can hold several properties. Use one property per website or app you want to measure separately.

Step 2: Add a web data stream

A data stream is the source that sends data into your property.

  1. When prompted to choose a platform, select Web.
  2. Enter your website URL (for example, www.example.com) and a stream name.
  3. Leave Enhanced measurement on. It automatically tracks page views, scrolls, outbound clicks, site search, file downloads and some video engagement.
  4. Click Create stream.

You will now see your measurement ID, in the format G-XXXXXXXXXX. Copy it.

Step 3: Install the Google tag on your site

Choose the method that matches how your site is built.

MethodBest forWhat you do
Website builder integrationSquarespace, Wix, Shopify and similarPaste the G- measurement ID into the analytics setting
CMS pluginWordPress and other CMSsInstall an analytics plugin and connect GA4
Manual codeCustom or static sitesPaste the Google tag code into every page’s head
Google Tag ManagerSites that need several tags or custom eventsAdd a Google tag in Tag Manager using your measurement ID

Using a website builder

Most hosted builders have a built-in field for Google Analytics, usually under settings, marketing or integrations. Paste your G- ID, save, and publish. If you are still choosing a platform, see the best website builders.

Adding the code manually

  1. In your data stream, click View tag instructions and choose Install manually.
  2. Copy the Google tag code snippet.
  3. Paste it immediately after the opening <head> tag on every page. On most sites, that means editing one shared header template.
  4. Save and deploy your changes.

Using Google Tag Manager

If your site already uses Tag Manager, create a new Google tag, enter your measurement ID, set it to fire on all pages, and publish the container. Do not also paste the manual code, or you may count visits twice.

Step 4: Check that data is coming in

  1. Open your website in a browser (ideally a private window, with ad blockers off).
  2. In Google Analytics, go to Reports and open Realtime.
  3. You should see at least one active user within a minute or two.

For more detail, Google’s DebugView (under Admin) shows individual events as they arrive when debug mode is enabled. Standard reports can take up to a day or two to fill in.

Step 5: Configure the basics

A few settings are worth changing early:

  • Data retention: under Admin, check how long user-level data is kept for exploration reports and adjust if needed.
  • Key events: mark important actions, such as form submissions or purchases, as key events so you can measure results.
  • Internal traffic: define your own IP addresses as internal traffic and filter them out so your visits do not skew reports.
  • Link Search Console: connecting Search Console shows which Google searches bring visitors. See how to get your website on Google.

Google Analytics uses cookies and processes data about visitors, so it has privacy implications.

  • Mention analytics in your privacy policy.
  • In the EU, UK and some other regions, analytics cookies generally need consent before they are set. Many sites use a consent banner together with Google’s consent mode.

Troubleshooting

  • No data in Realtime: check the measurement ID is correct, the site has been republished, and your browser is not blocking analytics.
  • Double counting: make sure the tag is installed only once, not through both a plugin and manual code.
  • Data from the wrong site: confirm each site has its own data stream or property.

Frequently asked questions

Is Google Analytics free?

Yes. As of October 2026, the standard version of Google Analytics 4 is free. Google also offers a paid enterprise version, Google Analytics 360, aimed at large organizations with higher data volumes.

What happened to Universal Analytics?

Universal Analytics has been retired. Standard Universal Analytics properties stopped processing data in July 2023, and Google Analytics 4 is now the only version of Google Analytics for new setups.

How long until data appears in Google Analytics?

Realtime and DebugView usually show activity within minutes of installation. Standard reports can take up to a day or two to populate fully.

Do I need a cookie banner for Google Analytics?

In the EU and UK, analytics cookies generally require consent before they are set, so many sites use a consent banner and Google's consent mode. Rules differ by country. See our guide on whether you need a cookie banner.

Sources

  1. Google Analytics Help: Set up Analytics for a website and/or app
  2. Google Analytics Help: Find your Google tag ID
  3. Google Analytics Help: Universal Analytics is going away
  4. Google Marketing Platform: Google Analytics
  5. Google Analytics Help: Google Analytics 360
Editorial Team

Plain-language guides to domain names and building websites. Articles are drafted with AI and list their sources; some are also reviewed by a person with domain-industry experience.