Google Analytics 4 Tracking Setup for WordPress
Quick answer: Use the free container builder wizard to select Google Analytics 4 and your events, enter your tracking ID, then import the generated file into Google Tag Manager - no manual tag setup needed for any of the 21 events below.
GA4 configuration and ecommerce event tracking via a native Google tag. This container uses a native GTM tag type for this platform.
Build my Google Analytics 4 container →
Events you can track
conversion events
- Google Analytics 4 Form Submission event setup
- Google Analytics 4 HubSpot Form Submission event setup
- Google Analytics 4 Contact Form 7 Submission event setup
- Google Analytics 4 WPForms Submission event setup
- Google Analytics 4 Gravity Forms Submission event setup
- Google Analytics 4 Comment Submission event setup
- Google Analytics 4 Newsletter Signup event setup
- Google Analytics 4 User Login event setup
- Google Analytics 4 User Registration event setup
- Google Analytics 4 Calendly Booking Scheduled event setup
- Google Analytics 4 Live Chat Started event setup
engagement events
- Google Analytics 4 Page View event setup
- Google Analytics 4 Scroll Depth event setup
- Google Analytics 4 Outbound Link Click event setup
- Google Analytics 4 File Download event setup
- Google Analytics 4 Phone Number Click event setup
- Google Analytics 4 Email Link Click event setup
- Google Analytics 4 WhatsApp Click event setup
- Google Analytics 4 Site Search event setup
- Google Analytics 4 Video Play event setup
- Google Analytics 4 Video Complete event setup
By Humayun Kabir Naim — Last updated: 7 November 2026
To track a WordPress site in GA4 through GTM, you need one Google tag loading on every page, Enhanced Measurement switched on in the GA4 data stream, and manual GTM triggers only for the events Enhanced Measurement cannot see properly — above all, successful form submissions. Enhanced Measurement handles scrolls, outbound clicks, file downloads, site search, and embedded video. What it cannot tell you is whether a visitor actually sent your contact form, so generate_lead is the piece you build by hand. Below: the fast route with our free container, or the same setup built manually.
What gets tracked
A WordPress site has nothing to sell, so what matters is engagement and lead events, not ecommerce. If an event below is missing, the matching GA4 report stays empty — no setting inside GA4 can fill it in later.
| WordPress action | GA4 event | How it is captured |
|---|---|---|
| Any page or post is viewed | page_view | Google tag in GTM |
| A contact or quote form is successfully submitted | generate_lead | GTM trigger (see Route 2, Step 3) |
| A PDF, document, or other file is downloaded | file_download | Enhanced Measurement |
| A link to another website is clicked | click | Enhanced Measurement |
| A visitor scrolls to the bottom of a page | scroll | Enhanced Measurement (fires once, at 90%) |
| An embedded YouTube video is played | video_start, video_progress, video_complete | Enhanced Measurement |
| A visitor uses the site search | view_search_results | Enhanced Measurement (reads the s URL parameter) |
| A call-to-action button, phone number, or email link is clicked | click or a custom event | GTM Click trigger |
Each event carries useful parameters — file_name and file_extension on downloads, link_url on outbound clicks, percent_scrolled, search_term. For generate_lead, add the form's name or ID yourself, so contact and quote forms do not land in GA4 as the same lead.
The split matters. Enhanced Measurement events are switched on per data stream in GA4 (Route 2, Step 2) — no GTM tag is needed. Manual events need a GTM trigger and tag. The mistake to avoid is building both for the same action: a manual click event alongside Enhanced Measurement's counts every outbound click twice. Pick one source per event.
Running a shop instead? WooCommerce needs ecommerce events, not engagement events — follow the WooCommerce + GA4 guide. See all options on the WordPress hub.
Before you start
- GTM installed on the site, once. Most WordPress sites use the free GTM4WP plugin — install it and paste your container ID in its settings. A theme setting or header/footer plugin can do the same job — but only one method may install it.
- No other GA4 sender. This is the classic WordPress double-install problem. Site Kit by Google, analytics plugins, and many themes can each add their own gtag.js for the same Measurement ID alongside GTM — and two senders means every pageview counted twice. GA4 must be sent through GTM only: remove the GA4 tag everywhere else (Site Kit can stay for Search Console, just not its Analytics tag).
- A GA4 property and web data stream, and its Measurement ID (starts with
G-). - Admin access to WordPress, GTM, and GA4 — to remove duplicates, publish, and check DebugView.
Route 1: Use the free TagManagerBuilder container
Open the GTM Container Builder, choose WordPress, then GA4, and tick the events you want. Enter your Measurement ID, download the JSON, and import it in GTM via Admin → Import Container with Merge → Overwrite conflicting tags, triggers, and variables. Test with the testing section below before publishing. Import failed? See the GTM container import error guide.
Note: the container does not replace GTM4WP. GTM4WP installs GTM; the container holds the tags and triggers. You need both — and you need Route 2's Step 2, because Enhanced Measurement lives in GA4, not in a container.
Route 2: Build it manually in GTM
Step 1 — Base Google tag
Tags → New, choose the Google Tag type, enter your Measurement ID (for example G-EXAMPLE123), and set the trigger to Initialization – All Pages. This tag sends page_view and carries the Enhanced Measurement events below. If your container already has one for the same ID, keep it and skip this step — two base tags double your pageviews.
Step 2 — Check Enhanced Measurement in GA4
In GA4, go to Admin → Data Streams, open your web stream, and open Enhanced measurement. These settings live in GA4, per stream — there is no switch for them in GTM, which is why "the tag loads through GTM" does not by itself guarantee these events arrive. Leave these on:
- Scrolls — one
scrollevent at 90% of the page - Outbound clicks —
clickfor links leaving your domain - Site search —
view_search_results; WordPress search uses thesparameter, already a GA4 default - File downloads —
file_downloadfor PDFs and documents - Video engagement — for YouTube embeds with the JavaScript API enabled
- Form interactions — leave it on if you like, but read Step 3 before trusting it
Step 3 — Track form submissions properly
Enhanced Measurement watches for submit attempts. Most WordPress form plugins submit by AJAX without a page load — and an attempt is not a lead: a visitor who fails validation has not contacted you. Track successful submissions, in one of three ways:
- Element Visibility trigger (works with almost every form plugin). Contact Form 7, WPForms, and Gravity Forms all show a success message after a successful submit. Create an Element Visibility trigger with the Selection Method set to CSS Selector pointing at that message, firing Once per page. Attach a GA4 Event tag named
generate_lead. - A listener for the plugin's own success event. Contact Form 7 fires a DOM event called
wpcf7mailsenton success; Gravity Forms firesgform_confirmation_loaded, WPForms its own AJAX success event. A small Custom HTML tag turns the Contact Form 7 event into a clean dataLayer push:
Fire this tag on All Pages (or only pages with a form), then attach a GA4 event tag via a Custom Event trigger for<script> document.addEventListener('wpcf7mailsent', function(event) { window.dataLayer = window.dataLayer || []; window.dataLayer.push({ event: 'generate_lead', form_id: event.detail.contactFormId }); }, false); </script>generate_lead, withform_idas an event parameter. - A thank-you page. If your form redirects to a confirmation page, skip the listeners: create a GA4 Event tag named
generate_leadon a Page View trigger limited to that page's path. Simplest method, hardest to break — prefer it when offered.
Before building anything, check Preview: some setups (GTM4WP options, form-plugin add-ons) already push a dataLayer event on success. If one is there, you only need the trigger and the tag.
Step 4 — CTA and contact clicks (optional)
For clicks Enhanced Measurement does not cover — a "Get a quote" button, or tel: and mailto: links — enable the Click built-in variables, add a Click – All Elements trigger limited by Click URL or Click Classes, and send a GA4 event with a custom name (for example contact_click), not click.
Step 5 — Variables for later use (recommended)
Create a Data Layer Variable (Data Layer Version 2) for form_id, to send as a parameter, and switch on the built-in Click URL, Click Text, and Page Path variables. The same container can then feed WordPress + Meta without rebuilding. Save — then test before publishing.
Test it: GTM Preview and GA4 DebugView
- Click Preview in GTM and open your site in Tag Assistant.
- Browse like a visitor: open a post, scroll to the bottom, download a file, click an outbound link, use the site search.
- Submit each form with test details, then click
generate_leadin the Preview timeline and confirm your GA4 tag sits under Tags Fired, with the rightform_id. - Open the Data Layer tab for that event and confirm the values match what you pushed — not
undefined. - In GA4, open Admin → DebugView and repeat one form submission and one download — Enhanced Measurement events appear here too, confirming Step 2. DebugView is live; standard reports are not — judge the setup here.
- Only then click Submit in GTM to publish.
If a tag fires in Preview but nothing reaches DebugView at all, the problem is upstream — work through GTM Tag Fires in Preview but Events Don't Show in GA4 first.
WordPress-specific troubleshooting
Every pageview is counted twice. Look for a second sender, not a second trigger. Site Kit, an analytics plugin, a theme's Analytics setting, or a hardcoded gtag.js snippet is sending GA4 pageviews alongside GTM. Search your page source for your Measurement ID — it should load through GTM only. Remove the other sender; do not "fix" it by deleting the GTM tag. Check after purging your cache — an optimisation plugin can re-insert one.
Scrolls, downloads, or outbound clicks are missing. These are Enhanced Measurement events, and the toggles live in the GA4 data stream, not in GTM (Route 2, Step 2). Know the limits: scroll fires once at 90% — reading half a post produces no event — and file_download covers recognised extensions only.
A form event fires in Preview, but nothing lands in GA4. Usually the form redirects the instant the submit succeeds, and the page unloads before the GA4 hit finishes sending. The durable fix is to track the thank-you page itself (Step 3, method 3). With no redirect, check DebugView before rebuilding.
The same click or download appears twice. You built it twice: once in Enhanced Measurement, once as a GTM trigger with the same event name. Decide which source owns that event — Enhanced Measurement is usually enough — and switch the other off.
Every visitor looks like they refused consent. Usually a cookie/CMP plugin that shows a banner but never sends Consent Mode signals to GTM, or sends defaults after the Google tag has fired. Check the consent state in Preview's Consent tab on first load, and test your banner with the Consent Mode Checker.
Landing page shows as (not set). Sessions that begin with an event but no page_view produce this — commonly when a redirect (from a redirection plugin, or an http/www clean-up) delays the first pageview, or the tag loads late so a click or form event lands first. Fix the redirect chain so the real page loads once, and keep the trigger on Initialization – All Pages so the pageview is the session's first hit.
Frequently asked questions
Do I still need GTM4WP if I use the TagManagerBuilder container?
Yes, in most setups. GTM4WP installs the GTM container; the container holds the tags, triggers, and variables. If your theme already installs GTM cleanly, GTM4WP is optional — but never run both.
Should I use Enhanced Measurement or GTM triggers?
Both, split by event. Enhanced Measurement for scrolls, outbound clicks, downloads, site search, and video. GTM triggers for successful form submissions and specific button clicks, where you need to know the action completed. Never run both sources for the same event name.
I use Site Kit. Can I keep it and use GTM too?
Yes — Site Kit is fine for Search Console, AdSense, and PageSpeed. The problem is its Analytics tag: if Site Kit places the GA4 snippet and GTM sends GA4, every hit is duplicated. Keep one sender for GA4 and disconnect the Analytics tag in the other.
How do I track Contact Form 7 submissions in GA4?
Not with a pageview — CF7 submits by AJAX and shows a success message instead of loading a new page. Either watch for that message with an Element Visibility trigger, or listen for CF7's wpcf7mailsent event and push a generate_lead dataLayer event, as in Step 3. Both fire only on success, which is what makes them leads rather than attempts.
Why does scroll depth only ever show 90%?
Because that is the one threshold Enhanced Measurement sends. If you need 25%, 50%, and 75% milestones, turn its scroll toggle off and use GTM's built-in Scroll Depth trigger. Do not run both.
What changes if I add WooCommerce later?
These events keep working, but a shop needs the ecommerce set — view_item, add_to_cart, purchase, and the rest — with product and order data attached. Follow the WooCommerce + GA4 guide when you add the shop, and keep this setup underneath it.