Linux 软件免费装
Banner图

GAinWP Google Analytics Integration for WP

开发者 tomdude
更新时间 2026年10月30日 05:28
PHP版本: 7.4 及以上
WordPress版本: 7.1
版权: GPLv2 or later
版权网址: 版权信息

标签

analytics google analytics google tag manager ga4 consent mode

下载

5.4.1 5.4.2 5.4.4 5.4.5 5.4.6 6.0.0 6.1.0 5.4.3

详情介绍:

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 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 Privacy
Bug reports and feature requests: GAinWP on GitHub.

安装:

  1. Install and activate GAinWP from Plugins → Add New.
  2. Go to Settings → Google Analytics.
  3. Choose Google Analytics 4 and enter your Measurement ID, or choose Google Tag Manager and enter your container ID.
  4. Save. Open your site in a private browser window and check Reports → Realtime in Google Analytics.

屏幕截图:

  • 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.

升级注意事项:

6.1.0 Adds form tracking for Gravity Forms, Contact Form 7 and WPForms (on by default: set your lead forms to Lead), goals with values, and a GA4 setup checklist. Page attribute parameters have new names: register them again in GA4 if you used the 6.0 names. 6.0.0 Major update for Google Analytics 4. Universal Analytics is retired: after updating, enter your GA4 Measurement ID under Settings > Google Analytics. Dashboard reports have been removed.

常见问题:

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_category and component_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_complete until you do). In Google Analytics, mark generate_lead (and sign_up, if you use it) as a key event. Mark generate_lead, not GA4's own form_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 GAinWP comment 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 the gtag('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 as is_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 implementing GAinWP\Integrations\Integration, or FormSource for form plugins). An integration's ajax_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's get() and set() 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.

更新日志:

6.1.0 6.0.0 5.4.6