Skip to content
Arrow keys to move, Enter to open, Esc to closeAll results
SEO and Marketing · Guides

How to Set Up GA4 on WordPress

A practical guide to GA4 on WordPress: how events replace sessions, three ways to install, consent, internal traffic, key events, WooCommerce tracking and how to verify it.

Written by
WPresident Editorial
Topic
SEO and Marketing

Most WordPress sites get Google Analytics 4 the same way. Someone pastes a Measurement ID into a plugin, sees a number appear in the Realtime report, and calls the job done. Six months later the owner asks how many people filled in the contact form last quarter, or which blog posts lead to sales, and the property cannot answer. The tag was installed, but the measurement was never designed. Pageviews are probably inflated by a second tag hiding in the theme, the editor’s own visits are in the totals, nothing was ever marked as a key event, and the data retention setting that decides how far back detailed reports can reach is still on its short default.

The single most useful idea in this guide is that GA4 is an event stream. Every interaction it records, whether a page view, a scroll, a click on a PDF link or a purchase, is an event: a name plus a bundle of parameters. Sessions, users and conversions are not things the browser sends. They are things GA4 builds out of events when it processes them. Once that model is clear, most of the confusing behaviour around GA4 becomes predictable. Installing means getting the right events to leave the browser exactly once. Configuring means deciding which events matter to your business and naming them properly. Verifying means confirming that what left the browser arrived intact and was interpreted the way you intended. Privacy means controlling when events are allowed to leave and what they contain.

A second idea follows from the first: almost everything in GA4 applies going forward, not backward. Filters, key event flags, custom dimensions and consent settings change what is recorded from that moment on and rarely repair history. So the sensible order is to design first, install second, verify third, and only then let the numbers shape any decisions.

This guide follows that order. It starts with how GA4 differs from the Universal Analytics model that older tutorials describe and what happens to an event between the browser and the report. It then covers the account, property and data stream and compares the three ways of getting the tag onto WordPress: a plugin, Google Tag Manager, or code. Consent, filtering your own traffic, key events for forms, WooCommerce tracking, verification and common mistakes follow, and it closes with privacy-first alternatives, because for some sites GA4 is more tool than they need.

A few boundaries first. Google changes the GA4 interface and some defaults regularly, so menu names and limits are described at documentation level, with a note on what to verify on Google’s help pages. Any figures in examples are illustrative scenarios, not measurements. Code is meant for a child theme or a small custom plugin, never a parent theme file that an update will overwrite. And nothing in the consent and privacy sections is legal advice: privacy law varies by country and by the data you collect, and the person accountable for compliance on your site should make the final call.

If you only have an hour, spend it on four things: one tag, loaded once; consent handled the way your visitors’ locations require; your own traffic excluded; and two or three key events that match what the site exists to do. The rest of this guide explains how to get those four right.

Key points

  • GA4 records events with parameters; sessions, users and conversions are derived from events during processing, which is why old Universal Analytics numbers do not carry over.
  • Install the Google tag exactly once, through one route only (plugin, Tag Manager or code), and check the page source for a second Measurement ID before you trust any number.
  • Settings such as filters, key events, custom dimensions and retention mostly apply going forward, so configure them before you need the data.
  • Consent is a property of when and what you send: decide what loads before consent, what loads after, and what must never be sent at all, such as personal data in URLs.
  • Mark only the events that match business goals as key events, and for ecommerce send complete purchase data with a unique transaction ID that cannot fire twice.
  • Verify in layers: network request, DebugView or Tag Assistant, Realtime, and finally the standard reports a day or more later.

From sessions to events: what GA4 changed

Universal Analytics, the product GA4 replaced, was built around the session. A visit began, a series of hits was recorded inside it (page views, events, transactions), and reports were mostly questions about sessions: how many, where from, how many left after one page. Events existed, with a rigid category, action and label shape, but the page view was the centerpiece.

GA4 flips this. The page view is just another event, named page_view, and so is the start of a session (session_start) and the first visit by a new browser (first_visit). Each event carries parameters in a flexible name and value format, so a file_download event can carry the file name and extension, and a purchase can carry a transaction ID, a value, a currency and a list of items. Reports then ask questions of events: how many times did this event occur, how many users triggered it, what were the parameter values.

The practical consequences show up quickly on a WordPress site. The first is that the numbers will not match your old ones, and the gap is not a bug. Universal Analytics started a new session at midnight and whenever the campaign source changed. GA4 ends a session only after a period of inactivity, 30 minutes by default, so a reader who drifts across midnight or arrives from two campaigns in one sitting is a single session. GA4’s headline user metric is also different: active users, which is not the same population as the old user count. Comparing a GA4 year to a Universal Analytics year is therefore comparing two definitions, and historical Universal Analytics data does not flow into GA4.

The second consequence is that bounce rate has been replaced in the main reports by engagement rate. An engaged session is one that lasts longer than ten seconds by default, includes a key event, or includes at least two page or screen views. Engagement rate is the share of sessions that qualify, and the bounce rate GA4 still offers is simply the opposite. For a blog where readers arrive, read one post thoroughly and leave, the old bounce rate often looked alarming, and engaged sessions describe that behaviour more fairly, though they remain approximations.

Third, goals became key events. In Universal Analytics a goal was a separate object with a type: a destination page, a duration, pages per session or an event. In GA4 any event can be flagged as a key event, which in earlier GA4 versions and in many tutorials is called a conversion. This is simpler and more powerful, but it moves work to you: GA4 does not know that your contact form matters until you tell it which event represents a submission and flag that event.

Web and app data also share one model, which is why GA4 has data streams rather than views; a plain WordPress site uses one web stream. The comparison below sums up the differences that matter day to day.

Universal Analytics versus GA4: what changed for a WordPress site

Universal AnalyticsGA4
Basic unitHit, grouped into sessionsEvent with parameters
Describing an eventCategory, action, labelEvent name plus named parameters
EngagementBounce rate: single-page sessionsEngagement rate: engaged sessions
GoalsSeparate goal objectsAny event flagged as a key event
Session endsMidnight, campaign change or inactivityInactivity timeout only
Web and appSeparate propertiesStreams inside one property
Ad hoc analysisCustom reportsExplorations
The differences that explain why old tutorials, old plugins and old numbers do not translate directly.

Anatomy of an event: from browser to report

Knowing what happens to a single event explains most GA4 mysteries, so it is worth following one. A visitor opens a page on your WordPress site. If the Google tag is on the page and nothing blocks it, the browser loads a script from Google’s servers. That script checks for a first-party cookie named _ga, which stores a randomly generated client identifier. If the cookie is absent, it creates one; this is what makes a returning browser recognisable, and it is why the same person on a phone and a laptop looks like two users unless you also supply a user ID. A second cookie, named _ga_ followed by part of your Measurement ID, stores the current session ID and a session count.

The tag then sends the first event, usually page_view, to Google’s collection endpoint as a small web request. The request carries the event name, the client and session identifiers, and the automatically gathered parameters: the page address, the page title, the referrer, the language, the screen size and so on. If this is a new browser, the tag also sends first_visit, and if a new session is starting it sends session_start. Everything after this happens on Google’s side.

On Google’s side, processing does the work that Universal Analytics did in the browser. Location is derived from the request, with Google’s documentation stating that GA4 does not log or store IP addresses. Device and browser come from the user agent. Known bots and spiders are removed. Your data filters are applied. Sessions are assembled from events that share a session ID, traffic sources are attributed, and each event is stored with its parameters. Because the assembly happens after collection, the interesting numbers, like sessions, engagement rate and attribution, are results rather than raw measurements.

Timing matters too. The Realtime report is fed quickly and shows roughly the last thirty minutes of activity, which makes it the right tool for checking that an install works. The standard reports are built from fully processed data and can lag by many hours, and Google’s documentation warns that up to a day or two of delay is possible, so a missing number an hour after launch is not a failure. A BigQuery link can also export raw events for anyone who wants to query them directly.

Events come in four groups, and the difference affects how much work you have to do. Automatically collected events, such as page_view, session_start and first_visit, need no setup. Enhanced measurement events, toggled in the data stream, cover scrolls, outbound clicks, site search, file downloads, video engagement and some form interactions. Recommended events, such as login, sign_up, generate_lead and the ecommerce set, have names and parameters Google defines so built-in reports understand them, but you have to send them. Custom events are anything else you invent, and their parameters stay out of standard reports until you register them as custom dimensions or metrics, which is not retroactive. Events and parameters are also subject to quotas, so check current limits before designing a large custom scheme.

What happens to one event

  1. Page loadsThe Google tag script runs if nothing blocks it and consent allows it.
  2. Cookies read or setA client ID in the _ga cookie, a session ID in the _ga_ cookie for your stream.
  3. Event sentEvent name, parameters, client ID and session ID leave in one small request.
  4. ProcessingBots removed, filters applied, sessions and sources built, parameters stored.
  5. Realtime viewRoughly the last thirty minutes, available within moments.
  6. Standard reportsFully processed data, which can lag by hours.
The browser only collects and sends; sessions, sources and engagement are built afterwards on Google’s side.

Create the account, property and data stream

GA4 stores things in three nested layers, and understanding them prevents several expensive mistakes. The account is the top container. It holds users and properties, and it is where you decide who has access. A business normally needs one account. The property is where data and most settings live: reporting time zone and currency, data retention, filters, key events, custom definitions, links to Google Ads, Search Console and BigQuery. The data stream sits inside the property and represents one source of data, such as your website. A web stream is tied to a domain and has the Measurement ID that the tag uses.

The setup itself is a short sequence. Sign in to Google Analytics with a Google account your business controls, not a freelancer’s personal one, so access does not leave when they do. In the Admin area create an account if you do not have one, then a property, giving it a name, the reporting time zone, the currency and some business details. Create a web data stream by entering your site’s address and a stream name. GA4 then shows the stream details, including the Measurement ID, a string beginning with G-. Copy it; the rest of this guide uses it.

Pick the time zone and currency carefully. The time zone controls where each reporting day begins and ends, which matters if you compare daily numbers against store sales, and currency is the unit for revenue. Both can be changed later, but doing so can leave a visible discontinuity, so choose the real values at the start. If you sell in several currencies, check how Google reports events carrying a different currency code.

Several identifiers look similar and are not interchangeable. The Measurement ID starts with G- and goes into the tag or plugin. The numeric property ID is used by some integrations and by the API. A Google Tag Manager container ID starts with GTM- and identifies a container, not a property. A Google Ads tag ID starts with AW-. Pasting the wrong one is a common reason a fresh install records nothing, with a silent Realtime report instead of an error.

Two structural decisions are worth making now. First, never point staging or development copies at the live property, because test visits and half-built checkout flows pollute real data. Leave the tag off staging or give it a separate property. Second, if several domains belong to one journey, such as a main site and a separate booking domain, plan cross-domain measurement in the stream’s tag settings instead of treating each domain as its own property. It preserves the client ID across the hop, so one visit stays one session rather than appearing as a referral from your own site.

Finally, apply least access. Roles run from viewer to administrator, and an editor can change settings that alter data collection. Give each person the lowest role that works, review the list when contractors leave, and treat the administrator role like a hosting login.

The GA4 hierarchy

Google account and usersWho signs in, and which role they hold at account or property level.
AccountContainer for properties and for access management.
PropertyTime zone, currency, retention, filters, key events and custom definitions live here.
Web data streamOne site or domain, with the G- Measurement ID and enhanced measurement toggles.
Events and parametersThe stored data that every report and exploration is built from.
Permissions are decided at the top, settings in the middle and the Measurement ID at the stream level.

Plugin, Tag Manager or code: choosing a route

All three routes end with the same Google tag running on the same pages, so the question is not which one produces better data. It is where you want to make changes over the next several years, and who will be making them. Pick one route per property and write it down. Nearly every duplicated-tag problem in this guide starts with two routes being active at once.

A plugin keeps everything inside wp-admin. You connect a Google account or paste the Measurement ID, tick some options, and page views, enhanced measurement and basic reports appear. That suits a small site run by one person who wants a handful of events and a dashboard without leaving WordPress. The limit is whatever the plugin author has built, and the useful extras, such as ecommerce, form tracking and custom dimensions, are often reserved for paid tiers, which you should verify on the vendor page before choosing.

Google Tag Manager moves the tag out of WordPress and into a container you manage on Google’s side. WordPress holds only the container snippet, while tags, triggers and variables live in the container, with workspaces, a version history and a preview mode. It is the right route when you run more than one tool, when marketers need to add events without a developer, or when you want an audit trail. The price is indirection: new concepts to learn, a second place where tracking can break, and a container that anyone with publish rights can change.

Code gives the smallest footprint and the most control. One script, no extra interface, and changes that go through the same review as any other deployment. It suits a developer-run site with a version-controlled child theme or custom plugin and a short list of events. It is the least forgiving route for non-developers, and it is easy to lose by accident: deactivate the child theme or replace the file and tracking silently stops.

Two hybrids are common and sensible. The first is a plugin, or a few lines of code, whose only job is to place the Tag Manager container, with all tracking logic kept in the container. The second is a plugin for the base tag with no Tag Manager at all. The unsafe hybrid is a plugin’s built-in GA4 integration running while a GTM tag also sends the same page views. Switching routes later is possible but means re-verifying every event, so choose for who will maintain it, not for how fast you can finish today. The table below gives the headline differences.

The three install routes side by side

PluginTag ManagerCode
Setup effortLowestModerateHighest
Custom eventsLimited to what the plugin exposesBuilt with triggers and variablesAnything, each one maintained as code
Who changes itAnyone with wp-admin accessAnyone with container accessDevelopers, through deployment
Change historyRarelyVersions and preview built inVersion control, if you use it
Typical failureSilent duplicate with another tagUnpublished or mis-triggered tagCode lost in a theme change
Best fitSmall owner-run sitesSeveral tools, many eventsDeveloper-run, minimal tracking
None of the routes is more accurate; they differ in who can change tracking and how it fails.

Route one: a WordPress plugin

Plugin installs fall into two kinds. The first is a connector, such as Google’s own Site Kit plugin, which signs in to your Google account, reads your properties and places the tag for you, then shows summary reports in wp-admin. The second is an analytics dashboard plugin, such as MonsterInsights, which places the tag and adds its own reports, event tracking options and, in some tiers, ecommerce and form tracking. A third kind exists, plain header and footer script plugins, which do nothing except print the snippet you paste in. They are the simplest option and the easiest way to end up with a forgotten second tag.

The steps are similar across all of them. Install the plugin, then run its setup wizard. Either authorise the plugin with the Google account that owns the property or paste the Measurement ID you copied earlier. Confirm that the wizard selected the stream for your live site and not a staging one. Then exclude logged-in roles such as administrators and editors if the plugin offers it, check whether it adds its own tag or expects an existing one, and read what any consent or anonymisation setting actually changes before assuming it makes you compliant.

Be clear about what a plugin dashboard is. The reports inside wp-admin are a view of the data in GA4, fetched over Google’s reporting interface, not a second set of measurements. If the plugin loses its connection, the dashboard goes stale while collection carries on. Conversely, the tag can stop collecting while a dashboard still shows cached figures. Do not use the plugin’s report screen to prove that tracking works; use the real-time and debug tools described later.

Finally, options can live in two places. Enhanced measurement toggles belong to the data stream in GA4, while the plugin may expose separate switches for the same behaviours, such as outbound link tracking, and if both are on you may get overlapping events. Choose one owner for each behaviour, and when you remove a plugin, check the page source afterwards, since leftover settings or a cached page can keep an old tag alive.

monsterinsights.com
MonsterInsights product page with the headline The Best WordPress Analytics Plugin and icons for real-time analytics, e-commerce reports, GDPR analytics, user behavior, SEO ranking and data points.
A dashboard plugin such as MonsterInsights places the tag and adds reporting and event options in wp-admin; check which features each plan includes on the vendor page.

Route two: Google Tag Manager

Tag Manager has three moving parts. A tag is a piece of tracking code, such as a GA4 event. A trigger is the condition that fires it, such as a click on a link or a custom event in the data layer. A variable supplies values, such as the page path or a number read from the data layer. You build and test these in a container workspace, publish a version, and the live site starts using it with no WordPress change. WordPress only needs the container snippet, which Tag Manager gives you in an install dialog. It has a head part and a body part. Copy both exactly and place them using the standard wp_head action and the wp_body_open action; the second only works if your theme calls wp_body_open() after the opening body tag, so check that before assuming it is installed.

Inside the container, create a Google tag, which is the current name for what used to be the GA4 configuration tag, enter your Measurement ID, and fire it on the initialization trigger for all pages. Firing it early matters because other tags may depend on it and because consent defaults should be set before it runs. Then add GA4 event tags for specific actions. For a contact form that does not reload the page, the most reliable pattern is for the site to push a named event to the data layer when the form succeeds, and for the container to react to it:

window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
  event: 'generate_lead',
  form_id: 'contact',
  form_location: 'footer'
});

In the container you would create a custom event trigger matching the event name generate_lead, data layer variables for form_id and form_location, and a GA4 event tag that sends generate_lead with those two parameters. This data layer approach is sturdier than click-based or form-submission triggers, which depend on how the page markup behaves and break when a theme or form plugin changes. Use those built-in triggers as a quick start, not as the permanent design.

Always test in the container’s preview mode before publishing. It opens your site with a debug panel showing which tags fired on which events and why. Give each published version a clear name, because the version history is the audit trail you chose this route for, and restrict publish rights, since a container can run arbitrary scripts on every page, which makes it a security surface as well as a measurement tool.

Route three: the tag in code

Placing the tag in code means loading Google’s script and a short initialisation block on every public page. Put it in a child theme’s functions.php or, better, in a small custom plugin that survives theme changes. This is a minimal version using the standard head hook:

add_action( 'wp_head', function () {
    // Skip logged-in staff so editing and previewing do not count as visits.
    if ( is_user_logged_in() && current_user_can( 'edit_posts' ) ) {
        return;
    }
    $measurement_id = 'G-XXXXXXXXXX'; // replace with your Measurement ID
    $post_type      = is_singular() ? get_post_type() : 'listing';
    ?>
    <script async src="//www.googletagmanager.com/gtag/js?id=<?php echo esc_attr( $measurement_id ); ?>"></script>
    <script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());
      gtag('config', '<?php echo esc_js( $measurement_id ); ?>', {
        wp_post_type: '<?php echo esc_js( $post_type ); ?>'
      });
    </script>
    <?php
}, 1 );

A few details in that snippet carry the lessons of this route. The loader address is written without a protocol so the browser matches the page, and you can swap in the full address Google shows in your stream’s tag instructions. The priority of 1 prints the tag early in the head. The ID is held in one variable so it cannot drift between the loader and the config call. The extra wp_post_type value is a custom parameter that rides along with every event from this tag; it appears in reports only after you register it in GA4 as an event-scoped custom dimension, and only for data collected after that.

The staff exclusion has a catch that surprises many people. It runs on the server when WordPress builds the page. If a page cache stores the version built for an anonymous visitor and serves it to everyone, or if it serves logged-in users a cached copy, the condition is not evaluated the way you expect. Most caching plugins bypass the cache for logged-in users by default, but verify that for yours, and treat the code check as a convenience rather than a guarantee. The reliable way to exclude your own visits is the internal traffic filter in GA4, covered in a later section.

Keep the code under version control, comment which property it belongs to, and remove it before adding a Tag Manager or plugin route. If your site uses a consent tool, the consent defaults must run before the config call, which is covered next.

This section is orientation, not legal advice. Whether you need consent before GA4 runs, and what that consent has to look like, depends on where your visitors are, what law applies to you and what data you collect. Decide it with whoever is accountable for compliance on your site, and treat vendor settings as tools, never as proof that you comply.

The technical facts are simple enough. GA4 stores identifiers in cookies on the visitor’s device and sends events to Google. Many jurisdictions expect a prior choice from the visitor for that, and some rely on notice and opt-out instead. Google’s documentation says GA4 does not log or store IP addresses, but that does not settle consent questions, because the identifiers and the data transfer still exist. You need three decisions: what may load before the visitor chooses, what changes after, and what must never be sent.

Google’s consent mode is the mechanism that connects your banner to the tag. It defines signals such as analytics_storage, ad_storage, ad_user_data and ad_personalization. You set a default state before any Google tag loads, usually denied, and update it when the visitor chooses:

window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('consent', 'default', {
  ad_storage: 'denied',
  ad_user_data: 'denied',
  ad_personalization: 'denied',
  analytics_storage: 'denied',
  wait_for_update: 500
});
// later, when the visitor accepts analytics cookies
gtag('consent', 'update', { analytics_storage: 'granted' });

There are two broad patterns. In the strict pattern the tag does not load at all until consent is given, so nothing is sent for visitors who decline or ignore the banner. In the consent mode pattern the tag loads with denied defaults and adjusts its behaviour, and Google describes limited, cookieless signals and modelling that can estimate part of the missing traffic under conditions you should verify in its documentation. Whether the second pattern is acceptable for your audience is a legal judgement, not a technical one. Either way, use a consent plugin or consent management platform that integrates with consent mode, test it by clearing cookies and walking through the banner, and confirm that the cookies you expect to be absent really are absent before the choice.

The third decision, what never to send, is where WordPress sites leak most. Google’s terms forbid sending personally identifiable information to Analytics, yet it slips in through URLs. A form that redirects to a thank-you page with the visitor’s email in the query string, a password reset link, a page title such as a greeting with the member’s name, or a WooCommerce order-received address carrying an order key all end up in page address and title parameters. Open the pages report and look for query strings. GA4 also offers data redaction options for email addresses and chosen query parameters in the stream settings; verify the current options there. If you send a user ID for logged-in members, make it an internal identifier, never an email address, and treat it as personal data for your own policies.

Consent mode order of events

  1. Default state setDenied for storage and ad signals, before any Google tag runs.
  2. Google tag loadsIt reads the state and limits what it stores and sends.
  3. Banner appearsYour consent tool asks the visitor to choose.
  4. Choice madeAccept, reject or customise by category.
  5. Update callThe tool sends the new state, for example analytics_storage granted.
  6. Tag adjustsCookies and full identifiers are used only where granted.
The default has to be set before the Google tag loads, or the tag starts with its own assumptions.

Filter your own traffic and set the day-one data rules

Your team may be the most active visitor your site has: editors preview posts, developers reload pages, support staff click through checkout. On a small site that traffic distorts page views and conversion rates. GA4 handles it in two steps. First, in the web stream’s tag settings, define internal traffic: create a rule with a name, a value for the traffic_type parameter, usually internal, and one or more IP addresses or ranges. Events from those addresses then carry that parameter. Second, in the Admin area under data filters, use the Internal Traffic filter, which excludes events whose traffic_type matches the value you chose.

The filter has states, and the difference matters. In testing, events are tagged for comparison but still counted, so you can confirm the rule catches the right visits. When active, matching events are dropped permanently and cannot be recovered. Test first by visiting from your office network and checking that the events carry the parameter, then activate. IP-based rules have limits: staff on home connections with changing addresses, people on a VPN or phone, and remote contractors will not match. A separate developer traffic filter excludes events sent in debug mode, which helps keep test sessions out. For everyone else, combine the filter with the plugin or code exclusion for logged-in roles described earlier.

Next, the unwanted referrals list in the stream’s tag settings. If checkout hands customers to an external payment page and returns them afterwards, GA4 can treat the return as a visit referred by the payment provider, starting a new session and stealing credit from the real source. List those domains so they are ignored as referrers. The same applies to your own subdomains if you use cross-domain measurement incorrectly or not at all.

Then the retention setting, which is the one most often missed. For standard properties the detailed event-level data that Explorations use is kept for a short default period, with a longer option available; look in the data collection and modification settings under data retention and choose the longest period the interface offers. Standard aggregated reports are not affected, but older detailed data is deleted when the window passes, so raising the setting later does not bring it back.

Two more settings deserve a conscious choice. Google signals adds cross-device and audience features but can also change how privacy thresholds hide small counts, so decide it together with your consent approach. And the session timeout and engaged-session duration, adjustable in tag settings, alter every session-based metric from then on, so change them only deliberately.

Key events: tracking form submissions that matter

A key event is any event you flag as important. That is all there is to it, and it is also where most properties go wrong, because GA4 does not guess. The work has three parts: decide which actions represent value, make the site emit a clean event for each, and flag it. For a typical business site that means a lead event for the contact or quote form, a sign-up event for registrations or newsletter subscriptions, and, for a store, purchase and perhaps begin_checkout. Resist flagging page_view or scrolls, which turns the key event count into noise. Flag an event in the Events list or the Key events area of the Admin screen; a new event name can be added there before it has been seen. Check the counting setting, which can count every occurrence or once per session, and verify the default on Google’s help page.

The hard part is detecting a successful form submission, not a click on the submit button. A click is wrong whenever validation fails, and most forms submit by script without a page reload. The right detection method depends on the form, and the diagram below shows the decision.

If the form redirects to a thank-you page, the page view is your signal. Either fire your own event on that page, or use the Create event option in GA4 to build a new event from page_view where the page address contains the thank-you path. Created events apply only to data collected after you save them. If the form submits through script, listen for the plugin’s success signal. Contact Form 7, for instance, dispatches a browser event when mail is sent:

document.addEventListener('wpcf7mailsent', function (event) {
  gtag('event', 'generate_lead', {
    form_id: String(event.detail.contactFormId)
  });
});

This assumes the gtag function from the code route is available. With Tag Manager, push a named event to the data layer instead, as shown earlier. Other form plugins provide equivalents, and some include a built-in GA4 option; read each plugin’s documentation, and if you use the built-in option, confirm it does not duplicate an event that Tag Manager also sends. Whichever approach you use, never send what visitors typed into the form as event parameters: field values are personal data, and a form identifier is enough.

Finally, remember spam: bot submissions count as leads unless the success signal fires only for messages that passed your anti-spam checks. Compare GA4 leads against real enquiries for the first few weeks and treat a large gap as a bug.

How can the site tell that a form really succeeded?

What does the form do after a valid submission?
Redirects to a thank-you pageUse that page view as the signal, either by firing an event there or by creating an event from the page view.
Stays on the page and shows a messageListen for the plugin’s success event and send a lead event from it, or push it to the data layer.
Offers its own GA4 integrationUse it if it sends one event per real submission, and make sure Tag Manager is not duplicating it.
Offers none of theseAsk a developer for a success callback; do not fall back to counting button clicks.
Pick the most reliable success signal the form offers, never a click on the submit button.

WooCommerce tracking basics

A store raises the stakes, because the data now feeds decisions about money. GA4’s built-in monetisation reports work only when the recommended ecommerce events arrive with the right names and parameters. The journey runs from view_item_list on shop and category pages, through select_item, view_item, add_to_cart and view_cart, to begin_checkout, add_shipping_info, add_payment_info and finally purchase. Each event carries an items list with fields such as item_id, item_name, price and quantity, and purchase also needs a transaction_id, a value and a currency code.

WooCommerce does not send these events by itself, so something has to. The options are an official Google Analytics integration extension from WooCommerce, an analytics plugin with an ecommerce feature (often limited to a paid tier), a data layer plugin that feeds Tag Manager, or custom code on WooCommerce hooks. Verify current features on each vendor page, then judge your pick by the checks below.

First, purchase must fire once. The order-received page can be reloaded, bookmarked or reopened from a confirmation email, and a naive implementation sends the event every time. Good ones record that the order was already tracked. Test by reloading the page and watching DebugView. A unique transaction ID helps GA4 and you spot repeats, but do not rely on it as your only defence.

Second, use the same item identifier everywhere, whether product ID or SKU, and decide how variations are represented. Mixed identifiers split one product into several rows and wreck funnel reports. Third, decide what value means, since Google’s documentation defines how it relates to item prices, tax and shipping; follow that definition once and write it down so differences from WooCommerce reports are explained rather than mysterious.

Fourth, keep cart, checkout, account and order-received pages out of the page cache. WooCommerce marks them as not cacheable and well-built caching plugins respect that, but verify yours, because a cached confirmation page could replay one customer’s order data to another. Fifth, if payment happens on an external page, add that domain to the unwanted referrals list so returning customers are not credited to the payment provider.

Finally, set expectations. GA4 will never match WooCommerce exactly: blockers, declined consent and closed tabs lose some hits, and refunds are not tracked by simple client-side setups. WooCommerce is the book of record for revenue; GA4 shows behaviour. A steady ratio between them is normal, while a sudden change in that ratio is the sign of a tracking break.

The ecommerce event path through a WooCommerce store

Shop or category pageview_item_list
Click on a productselect_item
Product pageview_item
Add to basketadd_to_cart
Basket pageview_cart
Checkout startsbegin_checkout
Shipping and payment stepsadd_shipping_info and add_payment_info
Order receivedpurchase, once only, with a unique transaction_id
Each stage should send one recommended event, and only the last one carries the money.

Verify your setup and fix the common mistakes

Verify in layers, from the fastest and most technical to the slowest and most authoritative. Start with the page source: search for G- and GTM- to see which IDs the page actually contains. From a terminal, a one-line check lists the IDs and how often each appears:

$ curl -sL example.com | grep -oE 'G-[A-Z0-9]{6,}|GTM-[A-Z0-9]{4,}' | sort | uniq -c

Replace the example address with your own. Seeing the same Measurement ID twice in the HTML is a strong hint of double tagging, though it can also be the loader address plus the config call, so look at the network requests too. Tag Assistant, Google’s debugging tool, connects to your site and reports which Google tags it found and whether they fired. DebugView in GA4 shows events from debug-mode devices as a live stream with parameters, which is where you confirm that a test form submission produced exactly one lead event. Tag Assistant, the Tag Manager preview and the debug_mode parameter all enable it. The Realtime report shows the last half hour of activity. Only after a day or more should you trust the standard reports.

The recurring faults are few. Double tagging comes from a plugin plus a hardcoded snippet, a theme settings field, a page builder’s custom code area or a Tag Manager tag all carrying the same ID. It inflates page views and distorts engagement. Optimisation plugins that delay JavaScript until the first interaction postpone the tag, so quick visits vanish; exclude the Google tag from delay if you can, and clear caches after any change. Blockers and privacy browsers stop the tag for a share of visitors that you cannot measure, so never compare GA4 users with server logs expecting equality. Server-side tagging reduces the loss but adds hosting work and does not remove consent duties.

Others are quieter. A wrong or copied Measurement ID from a staging site sends data to the wrong property. A consent banner misconfigured to deny everything yields a flat, believable-looking report. Automated and fake traffic can still reach a property even though known bots are filtered, so odd spikes with no engagement deserve a check. And assuming settings are retroactive leaves people puzzled when a freshly flagged key event shows nothing for last month.

Where to verify, from fastest to most authoritative

How to read this: each row is one option, and its dot shows where it sits between Immediate and technical and Delayed and report-grade. Placement is an editorial judgement, not a measurement.

  1. 1Page source and network requestsShows what left the browser, not what Google kept.
  2. 2Tag Assistant or Tag Manager previewShows which tags fired and why.
  3. 3DebugViewShows events and parameters from test devices.
  4. 4Realtime reportRecent activity, good for a launch check.
  5. 5Standard reportsFully processed, trust them after the delay.
Positions are editorial: each layer answers a different question, so use more than one.

When a privacy-first alternative is the better answer

GA4 is built for marketing teams who connect analytics to advertising, audiences and exports. Many WordPress sites need much less: how many people read the guides, which pages bring enquiries, where traffic comes from. For those sites GA4 can be more interface, more configuration and more consent burden than the question deserves, and an alternative may fit better.

The alternatives fall into a few families. Some run inside WordPress and store data in your own database, with reports in wp-admin; Independent Analytics is an example of that style, and other plugins follow it. Some are hosted services built around simple, cookieless counting, such as Plausible, Fathom or Simple Analytics. Matomo can be self-hosted or used as a service and offers a broader feature set. Cloudflare offers a lightweight web analytics product too. Vendors in this space generally advertise privacy-friendly design, but those are their claims, so read each one’s documentation and get your own advice on consent.

The trade-offs are real. Cookieless counting often means you cannot recognise a returning visitor across days, so user and session figures are estimates built differently from GA4’s. Integrations with advertising platforms are narrower or absent. Self-hosted tools put updates, storage and backups on you, and a plugin that stores every visit in the WordPress database should be assessed for load on busy sites. Pricing models vary, so check each vendor’s current page.

A practical rule: choose GA4 if you run paid campaigns that need conversion data inside Google Ads, if you need audiences or a BigQuery export, or if the people who read your reports already know it. Choose a lighter tool if you mainly want to see readership trends, if your audience is sensitive about tracking, or if nobody will maintain a GA4 property. Running both is possible, and some teams do so while they compare, but it doubles the consent and performance questions. And whichever you choose, Search Console remains the source for search queries and rankings, because analytics tools cannot see what happens before the click.

independentwp.com
Independent Analytics product page with the headline Get Analytics You Understand, feature icons for campaigns, real-time, click tracking, ecommerce and form tracking, and a preview of its WordPress dashboard Pages report.
A plugin such as Independent Analytics keeps reporting inside wp-admin, one example of the lighter alternatives; review each vendor’s own privacy documentation before relying on it.

Checklist

  • Create the GA4 property with the correct reporting time zone and currency before collecting data.
  • Create a web data stream for the live domain only and copy the G- Measurement ID.
  • Choose one install route (plugin, Tag Manager or code) and note it where the team can find it.
  • View the page source and confirm the Measurement ID or container ID appears only where you expect.
  • Deactivate any second analytics plugin, theme tracking field or builder code area that carries the same ID.
  • Keep staging and development copies from sending data to the live property.
  • Review the enhanced measurement toggles and decide who owns each behaviour, stream or plugin.
  • Set consent defaults before the Google tag loads and test the banner with cleared cookies.
  • Check page addresses and titles for emails, names or order keys, and remove or redact any you find.
  • Define internal traffic, test the filter, then activate it.
  • Add payment gateway and other external domains to the unwanted referrals list.
  • Set data retention to the longest period the interface offers.
  • Flag only the events that match business goals as key events, such as a lead or a purchase.
  • Fire the form success event from a real success signal, not a button click, and register useful parameters as custom dimensions.
  • For WooCommerce, test that purchase fires once, reload the order-received page and confirm no repeat.
  • Keep cart, checkout, account and order-received pages out of the page cache.
  • Run a test visit and confirm the events in DebugView, then in Realtime.
  • Compare GA4 lead and order counts with real enquiries and WooCommerce orders after the first weeks.

About this guide. This is general guidance written by WPresident Editorial from documentation and widely used practice. WPresident has not benchmarked the products or methods described. Interfaces and plan limits change, so check the vendor’s current documentation before you act. Not legal, tax or financial advice. See our editorial policy.

Frequently asked questions

Do I need a plugin to add GA4 to WordPress?

No. A plugin is only one of three routes. You can place the Google tag with Google Tag Manager or with a few lines of code in a child theme or small custom plugin. The tag is the same in each case. Choose by who will maintain tracking, and use only one route per property so the same events are not sent twice.

Why do GA4 numbers differ from my old analytics?

GA4 counts differently. Sessions do not restart at midnight or on a campaign change, users are defined as active users, and engagement rate replaces bounce rate. Historical Universal Analytics data does not carry into GA4. Compare GA4 against itself over time, and treat any comparison across the switch as a comparison of two definitions.

How long until data shows up in GA4?

The Realtime report should show a visit within moments, covering roughly the last half hour. Standard reports are built from processed data and can lag by hours, and Google's documentation allows for a day or more. Check Realtime or DebugView to confirm an install, and wait before judging the standard reports.

Why is my pageview count almost double?

The usual cause is double tagging: the same Measurement ID loaded by a plugin and a hardcoded snippet, by a theme setting and Tag Manager, or by two plugins. View the page source or run a command that lists IDs, find the second source and remove it. Then clear caches and recheck page views in DebugView.

Do I need a cookie banner for GA4?

It depends on where your visitors are and on the law that applies to you, and this is not legal advice. Many places expect a prior choice before non-essential cookies or identifiers are set. Ask whoever is accountable for compliance, then configure the banner and Google consent mode to match that decision, and test it.

What is the difference between a key event and a conversion?

In GA4's interface, key events are the events you flag as important to your business, which older material calls conversions. Google now uses the word conversion in some advertising contexts. Practically, flag a small number of events such as a lead or a purchase, and check Google's help pages for current naming.

How do I stop my own visits being counted?

Define internal traffic in the stream's tag settings using your IP addresses, then turn on the Internal Traffic filter, testing it before activating. Because IP rules miss remote staff and changing addresses, also exclude logged-in roles in your plugin or code. Remember an active filter drops matching events permanently, so test first.

Why does GA4 show fewer orders than WooCommerce?

Blockers, declined consent, closed tabs and failed hits mean GA4 sees only part of the traffic, while WooCommerce records every order. Treat WooCommerce as the record of revenue and GA4 as behaviour. A stable ratio is normal. A sudden change in the ratio suggests a broken tag, a caching change or a duplicated event.

How long does GA4 keep my data?

For standard properties, event-level data used in Explorations is kept for a short default period, with a longer option in the data retention setting. Standard aggregated reports are not affected. Data older than the window is deleted, so raising it later does not restore anything. Check the current options on Google's help page and set it early.

Do I have to use GA4 at all?

No. If you need Google Ads conversion data, audiences or a BigQuery export, GA4 is a natural fit. If you mainly want to know what gets read and where visitors come from, a lighter privacy-focused tool may suit you better. Read each vendor's documentation, and decide consent with the person responsible for compliance.

W
Written byWPresident EditorialThe WPresident editorial team. Every article says whether it comes from hands-on use or from documentation, and anything paid for is labelled.

Keep reading

SEO and Marketing

How to Set Up Slim SEO on WordPress

A practical Slim SEO setup guide: what it does on its own, the few settings worth checking, titles, social previews, sitemaps, redirects, schema and how to verify.

Read more
WPresident Editorial

Get the Monthly Launch Report

One email a month: the best of last month's articles, new reviews and what changed in WordPress, without the noise.

No spam. Unsubscribe in one click.

Signed and sealed,
The WPresident
↑↓ move↵ openEsc closeAll results