Analytics

How to Set Up GA4 on WordPress (Properly): Tag Manager, Consent and Form Tracking

· 7 min read · By Panagiotis Spyropoulos

How to Set Up GA4 on WordPress (Properly): Tag Manager, Consent and Form Tracking

Getting a GA4 tag onto a WordPress site is easy. Getting GA4 data that you can make decisions with is a different job: the tag has to load once, respect consent, survive your caching plugin, and record the enquiries that actually matter. This guide covers the options, what we recommend for businesses, and the WordPress-specific problems we find most often in audits.

Three ways to add GA4 to WordPress

1. Site Kit by Google

Site Kit is Google’s own WordPress plugin. You sign in with your Google account, pick a GA4 property, and it places the Google tag for you. It also shows Analytics and Search Console summaries inside the WordPress dashboard, and it has a consent mode setting that works with the WP Consent API plugin and a compatible cookie banner.

  • Pros: quick, maintained by Google, no code, handy dashboard widgets.
  • Cons: limited control over events. Anything beyond the basics — a specific form, a phone click, a booking widget — still needs Tag Manager or custom code.

2. A Google Tag Manager container

Here you add the Tag Manager container snippet once, and every tag (GA4, Google Ads, Meta, LinkedIn) is managed inside GTM. You can add the snippet with a header-and-footer plugin such as WPCode, with a dedicated plugin such as GTM4WP, which also pushes useful WordPress data (post type, category, author) into the data layer, or directly in a child theme.

  • Pros: full control over what fires and when, versioning and preview mode, one place for all marketing tags, and changes without a developer touching the site.
  • Cons: someone needs to know GTM well. A messy container is as hard to audit as messy code.

3. Hard-coding gtag.js in the theme

You paste the Google tag directly into the theme’s header.

  • Pros: no plugin, nothing in between.
  • Cons: every change is a code change, and theme updates can overwrite it unless you use a child theme.

Our recommendation

For a business that runs paid campaigns or relies on enquiries, use Tag Manager. It is the only option that grows with you: form tracking, call tracking, consent, Google Ads conversions and staging all live in one versioned container. Site Kit is reasonable for a small site that only needs basic traffic reporting, and it can still be used for its dashboards with its own tag placement turned off.

Avoid double-tagging

The most common WordPress problem we find is GA4 loading twice. Typical causes:

  • Site Kit placing the Google tag and a GTM container sending GA4 as well.
  • An old analytics plugin left active after a migration to GTM.
  • A theme with a built-in “Google Analytics ID” field, filled in years ago.
  • A page builder or form plugin adding its own tracking.

Double-tagging inflates page views, distorts engagement metrics and can fire key events twice. Pick one source for the Google tag and remove the others. Open the page in Tag Assistant and check that only one GA4 measurement ID appears, and that it appears once.

If you have UK or EU visitors, the GA4 setup is not finished until consent is. Choose a cookie banner (a consent management platform) that supports Google Consent Mode v2, set consent defaults before any tag fires, and send an update when the visitor chooses. In GTM, use the banner’s own template where one exists, so the order of events is right.

Do not configure consent in two places. If Site Kit’s consent mode and your banner’s own consent mode are both active, they can conflict. We explain the four consent signals, basic vs advanced mode and the usual mistakes in our guide to Google Consent Mode v2.

Track the enquiries, not just the visits

Page views tell you about traffic. Key events tell you about business. For most lead-generation sites, set up at least:

  • generate_lead — a genuine successful form submission (quote, contact, demo request). This is one of Google’s recommended event names, so use it rather than inventing your own.
  • Phone clicks — clicks on tel: links, as a separate event such as phone_click.
  • Email clicks — clicks on mailto: links, as a separate event.
  • Bookings — a confirmed booking in your calendar tool, not a click on “Book now”.

Mark only the real business outcomes as key events in GA4, and import those into Google Ads. Phone and email clicks are useful signals, but a click is not a call, so decide deliberately whether they count as key events. Add a value to generate_lead if you know roughly what a lead is worth; it makes channel comparisons far more useful.

WordPress form pitfalls

Forms are where most WordPress tracking breaks:

  • AJAX submissions. Contact Form 7, Gravity Forms, WPForms and many page builders submit without reloading the page. GTM’s built-in form trigger often misses them, or fires on failed validation. Listen for the plugin’s success event instead — Contact Form 7, for example, dispatches a wpcf7mailsent DOM event only when the message has been sent — and push it to the data layer.
  • Button-click tracking. Counting clicks on “Submit” counts every attempt, including empty and invalid ones.
  • Thank-you pages. A redirect to /thank-you/ is simple to track, but the page can be reloaded, bookmarked or found in search. Make it noindex, and fire the event from the form’s success signal or only when the visitor arrived from the form.
  • Newsletter forms. Do not send newsletter sign-ups as generate_lead; give them their own event.

Cross-domain booking tools

If enquiries finish on another domain — a Calendly-style scheduler, a payment page, a booking engine — the visitor leaves your site and GA4 may credit the booking to a referral from your own website. Where the tool runs on a domain you can tag, configure cross-domain measurement in the GA4 data stream settings. Where it is an embedded widget, track the confirmation message the widget sends to your page, and add the tool’s domain to your unwanted referrals list.

Caching and optimisation plugins

Speed plugins are good for your visitors and frequently bad for your data. Features such as WP Rocket’s Delay JavaScript execution or LiteSpeed Cache’s delayed Load JS Deferred setting hold scripts back until the visitor interacts. A visitor who reads the page and leaves without scrolling or clicking may never be counted, and a cookie banner that loads late can leave tags waiting for consent that never arrives.

Exclude the GTM container, the Google tag and your consent banner from delay and combine/minify settings. WP Rocket has one-click exclusions for Google Analytics and Google Tag Manager; other plugins need the script names added by hand. Clear the cache after every tracking change, and test with the cache on, because that is what visitors get.

Keep internal and staging traffic out

  • Define your office and remote-team IP addresses as internal traffic in GA4 and activate the internal traffic filter (in Testing state first).
  • Make sure the staging copy of your WordPress site does not send to the live property. Many WordPress hosts create staging sites by cloning production, tags and all. We cover the hostname-based setup in how to set up a staging GA4 environment.

Check it before you trust it

  1. Tag Assistant / GTM Preview — submit each form, click each phone number, and confirm every tag fires once, with consent granted and denied.
  2. GA4 DebugView — confirm events and their parameters arrive as named.
  3. Realtime report — a final check from a normal browser session, outside preview mode.
  4. Next day — check the standard reports and Google Ads conversions once the data has been processed.

Repeat the check after plugin updates, theme changes and new forms: WordPress tracking rarely breaks on day one, but quietly months later.

Key takeaways

  • Site Kit is fine for basic reporting; for a business that runs campaigns or relies on enquiries, Google Tag Manager gives the control you need.
  • Load the Google tag from exactly one place, and configure consent in exactly one place.
  • Track successful form submissions as generate_lead, plus phone, email and booking events, and mark only real outcomes as key events.
  • Exclude your tags and banner from JavaScript delay in caching plugins.
  • Filter internal traffic, keep staging out of the live property, and test after every change.

If WordPress is still the right platform for you (see WordPress or custom web development), this setup is what our Google Analytics and Tag Manager service delivers. If you are not sure your current numbers are right, get in touch.

Contact

Start now.

Tell us a little about your business and we will show you where enquiries are being lost today.

We only use your details to get back to you. Privacy