-
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
Implement Enhanced Conversions support by hooking into the ninja_forms_after_submission event. This enables Site Kit to capture and send user data submitted via Ninja Forms for improved conversion attribution.
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 Ninja Forms, 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/ninja-forms.js:
- Leverage the existing
submit:responseevent listener already present in the file. - If the
gtagUserDatafeature flag is enabled using theisFeatureEnabledutility, add logic inside the event handler to:- Locate the
actionSubmithandler and receive thedataobject from the event. - Read the submitted form from
data.fields(a custom object that contains the form fields). - Iterate the fields object to extract user data.
- For each field, use the
classifyPIIutility function (implemented in Implement unified PII classifier for plugin form event data for ECEE #11252) to determine if it contains PII. - The
classifyPIIfunction returns eithernullor{ type: 'email' | 'phone' | 'name' | 'text', value: <normalized> }. - If the value wasn't normalized, normalize it using the
normalizeValue/normalizeEmail/normalizePhoneutility functions (implemented in Implement unified PII classifier for plugin form event data for ECEE #11252). - Only include names when the field metadata clearly indicates first name or last name (e.g., tokens like
first-name,fname,last-name,name,lname). This will be classified asnameby theclassifyPIIfunction. - If there are more than one name fields, treat the first one as the first name and the second/last one as the last name.
- If there is only one name field, treat it as the full name and attempt to split into
first_nameandlast_nameusing a space delimiter. - If the name field is not normalized, normalize it using the
normalizeValueutility function. - Structure the
user_dataobject using the following supported fields in Enhanced Conversions (if available):emailphone_numberaddress.first_nameaddress.last_name
- Inject the collected user data into the
gtagEventcall with the keyuser_data, like so:global._googlesitekit?.gtagEvent?.( 'submit_lead_form', { user_data: { ...normalizedUserData }, // Injected user data for Enhanced Conversions } );
- Do not pass the
user_dataproperty if no valid user data is available. - Pass the
user_dataeven if it contains only one supported field.
- Locate the
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 Ninja Forms and set up a few forms:
- A form without any PII fields (no names, email, or phone).
- A form with all PII fields (First name, Last name, Email, Phone number).
- Some forms with incomplete PII (e.g., first name only, first name + email only, email only, etc.).
- Using Tag Assistant, verify the
data_layerof thesubmit_lead_formevent:- A form with all PII fields should add a
user_dataobject to the Data Layer with the following format:{ "address": { "first_name": "...", "last_name": "..." }, "email": "...", "phone_number": "..." } - A form without any PII fields should not add the
user_dataobject. - 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
- A form with all PII fields should add a
Changelog entry
- Add Enhanced Conversions support for Ninja Forms 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