Add Google Analytics to a website: GA4 setup that will not bite you

A practical GA4 install checklist for UK B2B sites: tag choice, consent, and verification.

To add Google Analytics to a website in 2026, install GA4 using either the Google tag (gtag.js) or Google Tag Manager, not both. Then ensure your cookie consent setup controls analytics storage, and verify collection in GA4 Realtime within 10 to 15 minutes. Use Tag Assistant and DebugView to confirm events fire as expected.

In short

  • Pick one implementation: Google tag or Google Tag Manager, installing both can cause overcounting and messy data.
  • Treat consent as part of the GA4 install: PECR applies to cookies and similar storage and access technologies, and UK GDPR also applies when personal data is involved.
  • Do not rely on guesswork: GA4 Realtime is the fastest check for basic collection, DebugView is the fastest check for specific events.
  • If you are using GTM, you still need to configure a Google tag in the container and publish changes, simply adding the GTM snippet is not enough.
  • Document what you changed, when, and how you verified it, future you will thank you.
A laptop displaying an analytics dashboard with real-time data tracking and analysis tools.
Photo: Atlantic Ambience on Pexels

Most advice on how to add Google Analytics to a website skips the bits that cause real pain: double tagging, broken consent, and thinking it works because you can see a script in the page source.

If you want reliable GA4 data for a UK B2B site, do three things in order: choose one install method, wire it into your consent approach, then verify data collection properly.

Add Google Analytics to a website: what is the simplest correct setup?

If you are starting fresh, the simplest correct setup is:

  1. Create or open your GA4 property.
  2. Install GA4 using one method only, either:
    • Google tag (gtag.js) added to your site code, or
    • Google Tag Manager (GTM) with a Google tag configured inside it.
  3. Confirm data is arriving in Realtime.

Google’s own GA4 guidance makes two points that are easy to miss:

  • You can install GA4 using either the Google tag (gtag.js) or GTM.1
  • Data typically starts arriving quickly, but other reports can take longer to populate, so you should use Realtime to confirm collection first.2

If you work with multiple stakeholders (marketing, web dev, agencies), write down which method you are using and where it is implemented. This stops the most common failure: someone later adds the other method “just to be safe”.

Should you use Google tag (gtag.js) or Google Tag Manager?

Use GTM if you want to manage tags without code releases, add non Google tags, or maintain event tracking in one place. Google describes GTM as a system that lets you install and update tags without redeploying the site.3

Use gtag.js if you have a very simple implementation and you have comfortable access to your site templates. Google notes that gtag.js is only for Google services and does not support third party or custom tags.3

Two practical rules for UK B2B teams:

  • If you already have GTM on the site, use GTM for GA4 as well.
  • If you do not have GTM and do not need it, installing the Google tag directly can be quicker.

Whichever you pick, pick one.

Why is GA4 showing double pageviews? (usually, you installed both)

If your GA4 numbers look inflated immediately after “installing analytics”, check whether both GTM and the Google tag are firing.

Google’s GA4 troubleshooting documentation is blunt: you should use either the Google tag or Tag Manager, not both, because it can cause unintended consequences such as overcounting.4

How to fix it:

  • If you want to keep GTM, remove the separate Google tag snippet from the site templates.
  • If you want to keep the Google tag, remove the GTM container snippet.

Then re test (see the verification steps below).

For most UK B2B sites, yes, you need to treat analytics as part of your consent design.

The ICO’s guidance explains that PECR applies to technologies that store information or access information stored on a user’s device (their “terminal equipment”), and that PECR allows their use only in particular circumstances or with valid consent.5 The same guidance also states that where personal data is involved, UK GDPR applies too.5

This matters because a GA4 install is not just adding a script. In practice it often involves cookies or similar storage and access technologies, and you should align it with your cookie banner and consent choices.

A useful way to keep your team aligned:

  • Make your GA4 installation ticket include a checkbox for “consent behaviour verified”, not just “tag added”.

If you want a quick refresher on how visitor identification fits into UK rules, keep your internal reference link handy (for example, your team might already use Scout’s Website visitor identification: the UK guide as a starting point when discussing measurement and privacy).

If you use Google’s advertising and measurement stack, you should at least understand consent mode, because it is how Google tags can adjust behaviour based on consent signals.

Google’s developer documentation states that consent mode was updated in November 2023 and includes additional parameters, and that if you already use consent mode you should upgrade to consent mode v2.6

Separately, Google Ads documentation notes that the ad_user_data parameter is required for regions that require end user consent, including the United Kingdom.7

What to do this week if you are (re)installing GA4:

  • Ask: “Are we using consent mode, and if so is it v2?”
  • If your CMP or web dev partner says “we have a cookie banner, so we are fine”, push for a test: confirm what actually fires before consent.

How do you verify GA4 is installed properly?

Do not stop at “the code is on the site”. Verify with three checks.

1) GA4 Realtime

Google’s Analytics Help states that once you tag your site, Analytics starts sending data within 10 to 15 minutes, and you can confirm it in the Realtime report.2

Realtime is the fastest sanity check. It will not prove that all your events are correct, but it will tell you if anything is arriving at all.

2) Tag Assistant and GTM preview

If you are using GTM, use preview mode rather than guessing.

Google’s Tag Manager Help explains that preview and debug mode lets you browse a site as if your current container draft were deployed, so you can test before publishing.8 This is how you catch common problems like triggers not firing on certain templates, or events firing twice.

Also remember the basic GTM gotcha: adding the GTM snippet alone is not the same as configuring GA4 inside GTM. Google’s GA4 troubleshooting guidance says that when you use Tag Manager, you need to configure the GA4 configuration tag, which is now the Google tag.4

3) GA4 DebugView

When you are validating specific events (for example, form_submit, generate_lead, book_demo), DebugView is usually faster than waiting for standard reports.

Google’s documentation says you can monitor events in DebugView, and it references setting debug_mode to true in your Google Analytics event tag for monitoring.9

A simple workflow for a B2B site release:

  • Before release: GTM Preview, confirm tags fire where expected.
  • Immediately after release: GA4 Realtime, confirm activity is arriving.
  • For event tracking changes: DebugView, confirm the right event names and parameters.

A quick checklist for a clean GA4 install (copy into your ticket)

  1. Chosen install method: Google tag or GTM (one only).4
  2. If GTM: Google tag configured in container and published.10
  3. Consent: cookie banner behaviour validated for analytics storage, aligned to PECR and UK GDPR requirements.5
  4. Verification: Realtime shows your test session within 10 to 15 minutes.2
  5. Debugging: DebugView confirms the events you care about (especially forms).9
  6. Change log: date, who changed what, where implemented, and how it was verified.

If you want to keep measurement discussions concrete with stakeholders, it helps to define what “good tracking” looks like in plain language: not “GA4 installed”, but “we can see visits, key conversions, and can explain gaps”. For teams that also use company identification, it can be worth adding the same discipline to your visitor matching approach: agree what confidence means before you act on it (Scout explains this in its confidence score guide).

Frequently asked questions

How long does it take for GA4 to start showing data after you install it?

Google says Analytics starts sending data to your property within 10 to 15 minutes after you tag your site. To confirm quickly, use the Realtime report, because other reports can take longer to populate.

Can I install GA4 with Google Tag Manager and also paste the Google tag into the website code?

Google advises using either the Google tag or Tag Manager, not both. Installing both can lead to unintended consequences such as overcounting, so pick one method and remove the other implementation.

If I already have GTM installed, do I still need to configure GA4 inside GTM?

Yes. Google’s troubleshooting guidance notes that when you use Tag Manager, you need to configure the GA4 configuration tag (now called the Google tag) and ensure it has an appropriate trigger, typically on page load.

Does PECR apply to analytics tools like Google Analytics?

The ICO explains that PECR applies to technologies that store information or access information stored on a user’s device, and those technologies can only be used in particular circumstances or with valid consent. Where personal data is involved, UK GDPR also applies.

What is the best way to test whether GA4 events are firing correctly?

Use a combination of tools. Check GA4 Realtime to confirm data is arriving, then use Tag Manager preview mode to see which tags fired on each page. For event level validation, use GA4 DebugView to monitor your test events more precisely.

Sources

  1. Google Analytics Help: Set up your Google tag in Google Analytics support.google.com
  2. Google Analytics Help: Confirm data is being collected support.google.com
  3. Google for Developers: Tagging for Google Analytics (GA4 tag options) developers.google.com
  4. Google Analytics Help: Troubleshoot tag setup on your website (GA4) support.google.com
  5. ICO: What are storage and access technologies? ico.org.uk
  6. Google for Developers: Set up consent mode on websites developers.google.com
  7. Google Ads Help: Verify your consent signals support.google.com
  8. Google Tag Manager Help: Preview and debug containers support.google.com
  9. Google Analytics Help: Monitor events in DebugView support.google.com
  10. Google Tag Manager Help: Set up Google Analytics in Tag Manager support.google.com