| 开发者 | tomdude |
|---|---|
| 更新时间 | 2026年10月30日 05:28 |
| PHP版本: | 7.4 及以上 |
| WordPress版本: | 7.1 |
| 版权: | GPLv2 or later |
| 版权网址: | 版权信息 |
generate_lead; a sign-up form can send sign_up. Other forms send form_complete, so a newsletter or search form never counts as a lead. Field values are never sent.login and sign_up, and comments as comment_submit.rel="sponsored" links), same-page anchor clicks, and scroll depth at 25, 50 and 75%.gainwp* names) and events are pushed as { event, intelligence: { ... } }.[gainwp_useroptout] shortcode. A visitor's opt-out is honored even if the site later turns the shortcode off.Bug reports and feature requests: GAinWP on GitHub.
In Google Analytics, go to Admin → Data streams and open your web stream. The Measurement ID starts with G-.
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.
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.
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).
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.
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.
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.
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.
form_complete, or generate_lead or sign_up for forms you set to Lead or Sign-up, with the form's ID and name, including AJAX forms and forms that redirect.login and sign_up events for WordPress logins and registrations, and comment_submit for comments.gainwp.track() in JavaScript and a PHP recorder for sending your own events; gainwp_event, gainwp_event_recorded and gainwp_integrations hooks.content_author, content_category, content_tags, content_publish_month, user_status); publish_year removed. See "Upgrading from 6.0".gtag('config') instead of gtag('set'), so they reliably apply to every event.rel="sponsored" count as affiliate links.transport_type parameter.