-
Notifications
You must be signed in to change notification settings - Fork 330
Closed
Labels
Module: AdsGoogle Ads module related issuesGoogle Ads module related issuesP0High priorityHigh priorityTeam MIssues for Squad 2Issues for Squad 2Type: EnhancementImprovement of an existing featureImprovement of an existing feature
Description
Feature Description
To support Enhanced Conversions and improve measurement accuracy, Site Kit should integrate with OptinMonster by listening to its lead generation form submission events on the client side. This allows Site Kit to capture user data (e.g., email, name) at the time of form submission and send it to Google via gtag.
Refer to the Plugin Event Integration for more details.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- When a supported conversion event (e.g., form submission) occurs via OptinMonster, Site Kit should track the event and include any available user data (e.g., email, name, phone) in the event payload.
- The event should be sent using Site Kit’s internal
gtagEventmechanism. - The user data should be normalized but not hashed, following the official Google guidelines for normalization.
- User data should only be included if it can be reliably extracted.
- User data should be sent if it has at least one supported field.
- User data shouldn't be sent if it has no supported fields.
- This behavior should only occur when the
gtagUserDatafeature flag is enabled. - Refer to Enhanced Conversions Fields Reference for the full list of supported fields.
Implementation Brief
In assets/js/event-providers/optin-monster.js:
- Update the existing
om.Analytics.trackevent listener to support Enhanced Conversions:- Check if the
gtagUserDatafeature flag is enabled usingglobal._googlesitekit?.gtagUserData. - Extract user data from
detail.Campaign.Formusing agetUserDataForOptinMonsterfunction when the feature flag is enabled and form data is available. - Include the extracted user data in the
gtagEventcall as auser_dataproperty when valid user data is found. - Preserve existing event data (
campaignID,campaignType).
- Check if the
- Add a
getUserDataForOptinMonster( form )function to extract user data from OptinMonster forms:- Access HTML input elements from
form.inputs(array or object of HTML input elements). - Skip hidden fields to avoid false positives (same as WPForms pattern).
- Extract field metadata including
type,name,value, andlabelfrom each input element. - Use
document.querySelector()to find associated<label>elements for proper label detection. - Use the
classifyPIIutility to identify email, phone, and name fields from the form inputs. - Pass the detected fields to the consolidated
getUserDatautility function fromassets/js/event-providers/utils.jsto build the finaluser_dataobject. - Return
getUserData( detectedFields )to ensure consistent structure with other form providers.
- Access HTML input elements from
- Structure the
user_dataobject using the following supported fields available in OptinMonster forms:email(from email input fields)phone_number(from phone/tel input fields)address.first_nameandaddress.last_name(from name input fields, split if single field contains full name)
- Use the consolidated Enhanced Conversions utilities from
assets/js/event-providers/utils.js(implemented in Consolidate the Enhanced Conversions functions used to constructuser_data#11366):getUserData( fields )- Main utility to build the finaluser_dataobject structureclassifyPII- To identify PII field types from form inputsPII_TYPE- For PII type constants
- Do not hash the user data - only normalize it according to Google's guidelines.
Test Coverage
- No new tests are needed.
QA Brief
- Set up Site Kit with Analytics/Ads and enable conversion tracking.
- Enable the
gtagUserDatafeature flag. - Install the OptinMonster plugin and create an OptinMonster account.
- Note: You will need to provide credit card information to activate OptinMonster, even for the free trial.
- Setup a lead generation form (popup, slide-in, or inline) with the following fields:
- Email Address
- Name
- Phone Number
- Using Tag Assistant, verify the
data_layerof thesubmit_lead_formevent:- Verify that a
user_dataobject was added to the Data Layer with the following format:{ "address": { "first_name": "...", "last_name": "..." }, "email": "...", "phone_number": "..." }
- Verify that a
- Make other variations of the form with only a subset of the fields (a form with just the email address, a form with email and phone, a form with email and name etc.)
- A form with only a subset of fields should add the
user_dataobject, but without any of the missing PII fields.- In other words, the properties of
user_datashould never containundefinedor an empty string ("") as a value.
- In other words, the properties of
Changelog entry
- Add Enhanced Conversions support for OptinMonster by capturing and sending user data.
Metadata
Metadata
Assignees
Labels
Module: AdsGoogle Ads module related issuesGoogle Ads module related issuesP0High priorityHigh priorityTeam MIssues for Squad 2Issues for Squad 2Type: EnhancementImprovement of an existing featureImprovement of an existing feature