Analytics & Tracking

How to Add Google Tag Manager to WordPress (Step-by-Step GA4 Guide)

One container, every tag. Manage Google Analytics 4, conversion pixels and remarketing tags from a single dashboard, with no code and no waiting on a developer.

The Google Tag Manager accounts dashboard

If you have ever pasted a tracking snippet into your theme, lost it after an update, or waited days for a developer to add a single pixel, Google Tag Manager (GTM) solves that. You install one container on your site once, then manage every tag from the GTM dashboard. Nothing else touches your theme files again.

Heads up: Universal Analytics stopped collecting data in July 2023. This guide uses Google Analytics 4 (GA4), the current and only supported version. If you are following an older tutorial that mentions "UA-" tracking IDs or "Universal Analytics" tags, it is out of date.

Why use Google Tag Manager?

  • One place for every tag. GA4, Google Ads, Meta Pixel, LinkedIn, Hotjar and more, all managed from GTM.
  • No code, no theme edits. Add or change tags without editing WordPress files, so a theme update never wipes your tracking.
  • Faster, safer changes. Preview a change before it goes live, and roll back instantly if something breaks.
  • Better page speed. Tags load through one lightweight container instead of a dozen separate scripts scattered through your site.

Before you start

You will need three things:

  • Admin access to your WordPress site
  • A Google account (the same one you use for Google Business Profile is ideal)
  • About 20 minutes

Step 1: Create your Google Tag Manager account and container

  1. Go to tagmanager.google.com and sign in with your Google account.
  2. Click Create Account. Enter your business name and country.
  3. Under Container, enter your website domain and choose Web as the target platform.
  4. Click Create, then accept the terms of service.
  5. You will be shown two snippets of code and a container ID that looks like GTM-XXXXXXX. Leave this tab open, you will need it in a moment.
The Add a New Account screen in Google Tag Manager, with Account Setup and a Web container
Set up the account, then add a Web container for your site.

Step 2: Add the GTM container to WordPress

You have two reliable options. Pick one.

Option A (recommended): the GTM4WP plugin

The free GTM4WP (Google Tag Manager for WordPress) plugin places the container correctly for you and adds a rich data layer, so GTM can "see" things like post category, author, logged-in status and WooCommerce purchases.

  1. In WordPress, go to Plugins > Add New, search for GTM4WP, then install and activate it.
  2. Go to Settings > Google Tag Manager.
  3. Paste your GTM-XXXXXXX ID into the Google Tag Manager ID field.
  4. Set the container code placement to Codeless injection (or "Footer" if your theme blocks the default), then save.

Option B: a header and footer plugin (WPCode)

If you prefer to paste the official snippets yourself, use WPCode (formerly Insert Headers and Footers). In WordPress, you will find the header and footer settings under the plugin's menu.

The WordPress Settings menu with Header and Footer highlighted
Header and footer plugins add a settings page for pasting the snippets.
  1. Open the plugin's Header & Footer settings.
  2. Paste the first GTM snippet into the Header box (it goes as high in the <head> as possible).
  3. Paste the second GTM snippet into the Body box (it goes immediately after the opening <body> tag).
  4. Save your changes.
The Install Google Tag Manager dialog showing the head and body code snippets
GTM gives you two snippets: one for the <head>, one just after <body>.
Tip: Only install the container once. If you add GTM through both a plugin and your theme, tags can fire twice and inflate your numbers.

Step 3: Create your GA4 property and get the Measurement ID

  1. Go to analytics.google.com and sign in.
  2. In Admin (the gear icon), click Create > Property and follow the prompts for a GA4 property.
  3. Add a Web data stream for your site URL.
  4. Copy the Measurement ID. It starts with G- (for example G-ABCDE12345).

Step 4: Connect GA4 to your site through GTM

  1. Back in Google Tag Manager, open your container and click Tags > New.
  2. Click Tag Configuration and choose Google Tag (shown as "Google Analytics: GA4 Configuration" in some accounts).
  3. Paste your G-XXXXXXXXXX Measurement ID into the Tag ID field.
  4. Click Triggering and choose All Pages.
  5. Name the tag something clear like GA4 - All Pages and click Save.
Adding a new tag from the Google Tag Manager overview
Add a new tag from your workspace.
Choosing the Google Analytics tag type in Google Tag Manager
Choose the Google Analytics tag type, then point it at your GA4 ID.

Step 5: Test with Preview mode, then publish

  1. Click Preview in the top right of GTM and enter your website URL. Tag Assistant opens your site in a connected window.
  2. Browse a few pages. In the Tag Assistant panel, confirm your GA4 tag shows under Tags Fired.
  3. In Google Analytics, open Reports > Realtime and check that your own visit appears.
  4. Happy? Return to GTM and click Submit, add a version name, then Publish. Your tracking is now live.

What to add next

Once GA4 is firing, GTM makes it easy to layer on the tracking that actually informs decisions:

  • Key event (conversion) tracking, for form submissions, calls and bookings.
  • Google Ads conversion tags and remarketing.
  • Meta Pixel and other advertising tags.
  • Consent Mode v2, so your tags respect your cookie banner and stay compliant.

Frequently asked questions

Do I still need Google Analytics if I have Tag Manager?

Yes. They do different jobs. Google Analytics 4 collects and reports the data; Google Tag Manager is the delivery system that decides which tags fire and when. GTM sends data to GA4, it does not replace it.

Will Tag Manager slow down my website?

No, it usually speeds things up. GTM loads asynchronously and lets you manage many tags through one lightweight container, instead of hard-coding several separate scripts that each block rendering.

Can I remove the Google site tag (gtag.js) once GTM is set up?

If you added GA4 directly with the gtag.js snippet earlier, remove it after you move GA4 into GTM. Running both at once double-counts your traffic.

Which plugin is best for adding GTM to WordPress?

For most local businesses we recommend GTM4WP, because it adds a data layer that unlocks richer tracking with no code. If you only need to paste the raw snippets, WPCode is a clean, lightweight alternative.

Want this set up properly, without the guesswork?

We set up GA4, Tag Manager and conversion tracking for Newcastle businesses every week, so you can see exactly where your leads come from. Get a free, no-obligation audit of your current setup.

Get your free audit