Skip to content

Implement OptinMonster Integration for Enhanced Conversions #11126

@hussain-t

Description

@hussain-t

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 gtagEvent mechanism.
  • 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 gtagUserData feature 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.track event listener to support Enhanced Conversions:
    • Check if the gtagUserData feature flag is enabled using global._googlesitekit?.gtagUserData.
    • Extract user data from detail.Campaign.Form using a getUserDataForOptinMonster function when the feature flag is enabled and form data is available.
    • Include the extracted user data in the gtagEvent call as a user_data property when valid user data is found.
    • Preserve existing event data (campaignID, campaignType).
  • 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, and label from each input element.
    • Use document.querySelector() to find associated <label> elements for proper label detection.
    • Use the classifyPII utility to identify email, phone, and name fields from the form inputs.
    • Pass the detected fields to the consolidated getUserData utility function from assets/js/event-providers/utils.js to build the final user_data object.
    • Return getUserData( detectedFields ) to ensure consistent structure with other form providers.
  • Structure the user_data object using the following supported fields available in OptinMonster forms:
    • email (from email input fields)
    • phone_number (from phone/tel input fields)
    • address.first_name and address.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 construct user_data #11366):
    • getUserData( fields ) - Main utility to build the final user_data object structure
    • classifyPII - To identify PII field types from form inputs
    • PII_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 gtagUserData feature 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_layer of the submit_lead_form event:
    • Verify that a user_data object was added to the Data Layer with the following format:
      {
        "address": {
          "first_name": "...",
          "last_name": "..."
        },
        "email": "...",
        "phone_number": "..."
      }
  • 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_data object, but without any of the missing PII fields.
    • In other words, the properties of user_data should never contain undefined or an empty string ("") as a value.

Changelog entry

  • Add Enhanced Conversions support for OptinMonster by capturing and sending user data.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Module: AdsGoogle Ads module related issuesP0High priorityTeam MIssues for Squad 2Type: EnhancementImprovement of an existing feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions