sandywp / plugins / ga-in
GAinWP Google Analytics Integration for WP
Google Analytics 4 for WordPress that tracks results: form leads, sign-ups and goal values, with GA4's own event names and a setup checklist.
Ready in seconds.
v6.1.0 7,000+ installs WP 6.0+ PHP 7.4+

What you get inside
6 screens-
Choose Google Analytics 4 or Google Tag Manager and paste your ID. The status line shows what GAinWP is sending.
-
Goals: the results that matter on your site, each with a value in your currency.
-
Forms from Gravity Forms, Contact Form 7 and WPForms, each sending a lead, a sign-up or another event, with an optional value of its own.
-
WordPress and engagement events, and the page attributes sent with every event.
-
The GA4 setup tab: the custom dimensions to register, the key events to mark and the GA4 settings to check.
-
Privacy settings (Consent Mode v2 defaults, Do Not Track and Global Privacy Control, visitor opt-out) and role exclusions.
About this plugin
GAinWP adds Google Analytics 4 (or a Google Tag Manager container) to your site and sends the events and dimensions that show what your site achieves, not just how many people visit. It uses GA4’s own event names, so results work in GA4 reports, Google Ads and anything else that reads GA4. It has no dashboards or upsells, and your data goes straight to Google.
Track results, not just traffic
- Form leads: an event for every successful submission in Gravity Forms, Contact Form 7 and WPForms, whether the form uses AJAX, reloads the page or redirects to a thank-you page. Failed validation and spam don’t count. Set the forms that bring you business to Lead and they send GA4’s
generate_lead; a sign-up form can sendsign_up. Other forms sendform_complete, so a newsletter or search form never counts as a lead. Field values are never sent. - Goals with values: mark the results that matter as goals and say what each is worth, for example $100 for a lead. Goals send their value to GA4 and, through it, Google Ads; per-form values override the default.
- WordPress events: logins and registrations as GA4’s
loginandsign_up, and comments ascomment_submit. - Engagement events that GA4 enhanced measurement doesn’t cover: email and phone link clicks, affiliate link clicks (including
rel="sponsored"links), same-page anchor clicks, and scroll depth at 25, 50 and 75%.
Page attributes
Sent with every event, under GA4-style names: content type and ID (built into GA4), author, primary category (Yoast SEO and Rank Math’s primary category supported), tags, publication month, content group, and whether the visitor is logged in.
GA4 setup checklist
A GA4 setup tab lists exactly what to do in Google Analytics for your settings: which custom dimensions to register, which events to mark as key events, and which GA4 settings to change (currency, data retention, enhanced measurement, data redaction). It also warns when Site Kit by Google adds the same tag or events, which would count them twice.
Google Analytics 4 and Tag Manager
- Paste your Measurement ID (G-XXXXXXXXXX), or your Tag Manager container ID.
- In Tag Manager mode, page attributes go to the data layer (under their GA4 names and GAinWP 5.x’s
gainwp*names) and events are pushed as{ event, intelligence: { ... } }. - Cross-domain measurement, cookie domain and cookie lifetime settings, and an optional AMP container for AMP plugin Reader mode pages.
Privacy
- Google Consent Mode v2 defaults: leave them to your consent banner, deny in the EEA, UK and Switzerland only, or deny everywhere.
- Optionally skip tracking for visitors who send Do Not Track or Global Privacy Control.
- Visitor opt-out link or button with the
[gainwp_useroptout]shortcode. A visitor’s opt-out is honored even if the site later turns the shortcode off. - No personal data in events: email addresses and phone numbers are removed from link text and URLs, and authors are sent by display name only.
- Exclude logged-in user roles (and network super admins) from tracking. Post previews and the Customizer are never tracked.
Bug reports and feature requests: GAinWP on GitHub.
Upgrading from 6.0
- Form tracking starts on. Successful submissions send
form_complete, which nothing else sends, so leads your site already tracks another way aren’t counted twice. Set the forms that bring you business to Lead under Settings → Google Analytics → Forms, and remove any other lead tracking for them. Logins, sign-ups and comments are off until you turn them on. A notice lists what’s new. - Page attribute parameters have new names, matching GA4’s style:
post_authoris nowcontent_author,post_categoryiscontent_category,post_tagsiscontent_tags,publish_monthiscontent_publish_monthanduser_typeisuser_status.publish_yearwas removed: the month starts with the year. If you registered the old names as custom dimensions, register the new ones (the GA4 setup tab lists them). Tag Manager’sgainwp*data layer names are unchanged. - Page attributes are now sent with
gtag('config'), as Google recommends, and apply to every event. - The “Username” author format was removed; authors are sent by display name.
- Scroll depth stops at 75%: GA4’s own scroll event covers 90%.
- Engagement events now work in Tag Manager mode too.
Upgrading from 5.x
Version 6.0 is a rewrite for Google Analytics 4. Google stopped processing Universal Analytics data in July 2023, so 5.x has not been collecting anything since then.
After updating, go to Settings → Google Analytics and enter your GA4 Measurement ID. Until you do, GAinWP adds no tag and shows a reminder on the Dashboard and Plugins screens.
Carried over automatically:
- Tracking method, including Tag Manager containers. Tag Manager sites keep working with no changes; data layer variable names are the same as before.
- Custom dimension and data layer choices, which become page attributes.
- Email, phone, anchor, affiliate and scroll tracking, Do Not Track, opt-out, excluded roles, cross-domain domains, cookie domain and lifetime.
- Affiliate links are now matched by plain URL fragments such as
/out/instead of a regular expression. Simple patterns convert automatically; if yours can’t, the settings screen tells you and affiliate events stay off until you update it.
Removed:
- Dashboard reports, real-time stats, post reports and the front-end widget. They relied on Google APIs that were shut down. Use Google Analytics, or Site Kit by Google if you want reports in WordPress.
- Download, outbound link and form submit events: GA4 enhanced measurement records these itself.
- Google Optimize (discontinued by Google), Analytics on AMP pages, Universal Analytics ecommerce, sample rates, enhanced link attribution and the custom cookie name.
- IP anonymization (GA4 never stores IP addresses) and the remarketing switch (manage Google signals in Google Analytics instead).
- Custom event categories, actions and labels set with
data-vars-ga-*attributes. GA4 has no categories or labels, so tracked links send the standard event names. - Your stored Google sign-in and cached report data are deleted.
Opt-outs recorded by 5.x are still honored.
External services
GAinWP connects your site to Google so you can measure visits. It contacts no other service.
- Google Analytics 4 mode loads the Google tag (gtag.js) from googletagmanager.com on every page. The visitor’s browser then sends page views, the page attributes and events you enable, and standard browser data (such as page URL, referrer, screen size and language) to Google Analytics, under the Measurement ID you enter.
- Google Tag Manager mode loads your container from googletagmanager.com on every page. What it sends, and to whom, depends on the tags you configure in Tag Manager.
Nothing is sent to Google from your server, and nothing is sent before you enter an ID. Events that happen on the server (a login, a form submission) are passed to the visitor’s browser in a short-lived first-party cookie, gainwp_events_ followed by random characters, which holds only the pending event and is deleted when the event is sent or after a day. Visitors who opt out get a gainwp_optout cookie. Google’s Terms of Service, Privacy Policy and Google Analytics Terms apply.
Questions
- Where do I find my Measurement ID?
In Google Analytics, go to Admin → Data streams and open your web stream. The Measurement ID starts with G-.
- Why don’t page attributes or form names show up in my reports?
GA4 only reports custom parameters you register. The GA4 setup tab under Settings → Google Analytics lists the ones your settings send, such as
content_author,content_categoryandcomponent_name. In Google Analytics, go to Admin → Data display → Custom definitions and create an event-scoped custom dimension for each. Content type, content ID and content group are built into GA4.- How do I count form submissions as conversions?
Under Settings → Google Analytics → Forms, set the forms that bring you business to Lead (every form sends
form_completeuntil you do). In Google Analytics, markgenerate_lead(andsign_up, if you use it) as a key event. Markgenerate_lead, not GA4’s ownform_submit, which counts every submit attempt. Give leads a value under Goals to see the value they bring in GA4 and Google Ads.- Which form plugins are supported?
Gravity Forms, Contact Form 7 and WPForms (Lite and Pro). Contact Form 7 counts a submission once its email has been sent, which is when it reports success. Other plugins and themes can send their own events with
gainwp.track()or the PHP recorder (see below).- Does it work with cookie consent banners?
Yes. Most banner plugins set Google Consent Mode themselves, so leave “Consent mode default” set to “Not set”. Choose a denied option only if your banner sends consent updates but doesn’t set defaults.
- How do I check that it’s working?
View the source of any page while logged out and look for the
GAinWPcomment followed by the Google tag. Settings → Google Analytics also shows what is being sent. Logged-in users in excluded roles are not tracked, so test from a private browser window.- Can I use it alongside Site Kit or another analytics plugin?
Use only one plugin to add the Google tag, or page views are counted twice. Site Kit can show reports without adding the tag if you turn off its “Place Google Analytics code” setting. If Site Kit’s plugin conversion tracking is on, also turn it off when GAinWP tracks your forms, or leads count twice. GAinWP warns you when it sees either overlap.
- How can I customize the output?
Developers can use these hooks:
gainwp_gtag_config(filter): parameters of thegtag('config')command.gainwp_page_data(filter): page attributes before they are sent, keyed by parameter name (content_author, …). Keys from 6.0 (author, …) are still mapped.gainwp_exclude_tracking(filter): return true to skip tracking for the current request. For page output it runs after the query is parsed, so conditional tags such asis_page()work; it also runs when an event is recorded on the server, such as a login or form submission, with a second argument'event'(page output passes'page').gainwp_event(filter): change an event recorded on the server, or return null to drop it.gainwp_event_recorded(action): runs when an event recorded on the server is queued, for example to react to a lead.gainwp_integrations(filter): add or remove integrations (classes implementingGAinWP\Integrations\Integration, orFormSourcefor form plugins). An integration’sajax_events()names the browser events, such as a form plugin’s success event, after which events recorded during an AJAX request are sent.gainwp_consent_regions(filter): regions where consent defaults to denied.gainwp_scroll_thresholds(filter): scroll depth percentages.gainwp_gtag_script_path(filter): gtag.js URL, for example to use a proxy.-
gainwp_tagmanager_datalayer(action): change data layer variables with the tracker’sget()andset()methods.gainwp_gtag_commands still runs but is deprecated in favor of
gainwp_gtag_config.
To send your own events from JavaScript, call
gainwp.track( 'event_name', { parameter: 'value' } ); it works in both tracking modes and honors opt-outs. From PHP, call\GAinWP\Plugin::instance()->recorder()->record( 'event_name', array( 'parameter' => 'value' ) ); the event is sent from the visitor’s browser on their next page view, or right away after an AJAX submission in a supported form plugin.
sandywp / also on the shelf
Try another plugin
Site Kit by Google – Analytics, Search Console, AdSense, Speed
4.2 · 5M+ installs
Site Kit is a one-stop solution for WordPress users to use everything Google has to offer to make them successful on the web.
-
The best free Google Analytics plugin for WordPress. See how visitors find and use your website so you can grow your business…
WP Statistics – Simple, privacy-friendly Google Analytics alternative
4.1 · 500K+ installs
Cookieless, privacy-friendly WordPress analytics. Clear graphs and visitor data kept on your own server.
Spin up a real WordPress site in seconds.
Test plugins, build a demo, hand a client a link — then squash it and start again. No local setup, no Docker.