Skip to main content

How to Install Google Analytics 4 on Your Website

Google Analytics 4 shows how many people visit your site, where they come from and what they do: which pages they open, whether they click buttons, whether they send enquiries. Installation takes about fifteen minutes, but small mistakes at this stage can spoil your statistics for months.

Here’s the installation step by step: create a property and data stream, add the tag to your site in one of three ways, and check that data is actually coming in.


A bar chart with a growth line in a browser window, a step checklist and a question mark — a guide to installing Google Analytics 4

Before you start: check whether tracking is already there

A common problem is two tracking codes on one site: a developer added one to the template, and another was added through a plugin or Tag Manager. Then every visit is counted twice. Before installing, open your site, right-click → View page source and search for gtag and G-. If an ID is already there, find out whose property it is before adding a new one.

Step 1. Create a property

  1. Open Google Analytics with your company account.
  2. Go to Admin and click Create → Property. If you don’t have an account yet, you’ll be prompted to create one, and the first property will be set up inside it.
  3. Enter the name, reporting time zone and currency. The time zone matters: it decides which day visits are assigned to.
  4. Answer the questions about your industry and goals and click Create.

Step 2. Add a data stream for your site

  1. In Admin, under Data collection and modification, open Data streams.
  2. Click Add stream → Web.
  3. Enter your site URL and a stream name. Leave Enhanced measurement on: it automatically collects scrolls, outbound clicks, site search and file downloads.
  4. Click Create stream. The stream details will show an ID in the format G-XXXXXXXXXX.

Step 3. Add the tag to your site

The method depends on how your site is built. Choose one, not all of them.

Through your CMS settings

Many CMSs and site builders have a field for the Google Analytics ID — in the template, SEO extension or integration settings. Just paste G-XXXXXXXXXX there.

Through Google Tag Manager

If Tag Manager is already on your site or you plan to connect other services, install Analytics through it: create a Google tag with your ID and publish the container. I explained how in the article on installing Google Tag Manager.

Code by hand

  1. In the stream details, under Google tag, click View tag instructions and choose Install manually.
  2. Copy the whole snippet — from the <!-- Google tag (gtag.js) --> comment to the closing </script>.
  3. Paste it immediately after the opening <head> tag on every page. Usually that’s one place in the shared template.

Step 4. Check that data is coming in

  1. Open your site in a normal browser window without an ad blocker.
  2. In Analytics, open the Realtime report. Your visit should appear within a few minutes.
  3. If it doesn’t, wait: according to Google, data collection begins within 30 minutes of installation. If there’s still nothing after half an hour, check that the right ID is on the site and that the cookie banner isn’t preventing the tag from firing.

Standard reports fill in with a delay, sometimes up to 24–48 hours. That’s normal.

Cookie banner and consent mode. For visitors from the EU, Google Analytics needs to respect their choice in the cookie banner. If the banner is there but doesn’t pass consent to Google, part of your data will be lost or collected incorrectly. How to check it — in the article on checking Consent Mode v2.

What to set up right after installation

  • Data retention. By default, detailed data for explorations is kept for 2 months. Under Admin → Data collection and modification → Data retention you can extend it to 14 months.
  • Excluding your own visits. Staff visits distort the statistics of a small site. Exclude them by defining internal traffic by your office IP address and activating a data filter.
  • Link to Search Console. Then Analytics shows search queries and pages from organic search. How to add a site to Search Console — in a separate guide.
  • Key events. Enquiries, calls and purchases need to be marked as key events, otherwise Analytics won’t show which sources bring in customers.

Common mistakes

  • Two tracking codes on the site — visits are doubled.
  • The code is added only to the home page, not to the shared template of all pages.
  • The property is created on a contractor’s personal account.
  • Wrong time zone — visits “move” to the neighbouring day.
  • An old Universal Analytics code with a UA- ID is installed: that service no longer collects data.

In short

  1. Check the site for old or someone else’s tracking code.
  2. Create a property and a web stream, copy the G- ID.
  3. Install the tag one way: via your CMS, Tag Manager or code in <head>.
  4. Check your visit in the Realtime report.
  5. Extend data retention, exclude your own visits and mark key events.

Installing the tag is half the job: next come events, excluding your own visits and linking to advertising. If you want enquiries and purchases counted correctly from day one, we can set up Google Analytics 4 for you.