-
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 edd_complete_purchase event. This allows Site Kit to capture user data from Easy Digital Downloads purchases and send it for 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., purchase completion) occurs via Easy Digital Downloads, 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 includes/Core/Conversion_Tracking/Conversion_Event_Providers/Easy_Digital_Downloads.php:
- Update the
get_event_namesmethod to returnarray( 'add_to_cart' )by default, and conditionally include'purchase'only when thegtagUserDatafeature flag is enabled. - Update the
register_hooksmethod to:- Only register Enhanced Conversions hooks if the
gtagUserDatafeature flag is enabled. - Add a
wp_footeraction that callsmaybe_add_purchase_data_from_sessionto add purchase data on completion pages.
- Only register Enhanced Conversions hooks if the
- Add a
maybe_add_purchase_data_from_sessionmethod that:- Uses
edd_is_success_page()to detect EDD purchase completion pages. - Uses
edd_get_purchase_session()to retrieve purchase data from the EDD session. - Calls
get_enhanced_conversions_data_from_sessionto extract user data. - Adds the purchase data to the provided inline script reference for client-side consumption.
- Uses
- Add a
get_enhanced_conversions_data_from_sessionmethod that:- Calls
extract_user_data_from_sessionto extract and normalize user data. - Returns
array( 'user_data' => $user_data )if user data is available, or an empty array if not.
- Calls
- Add an
extract_user_data_from_sessionmethod to extract customer data from EDD session data and normalize it using theEnhanced_Conversionsclass methods. Do not hash the data. - Structure the
user_dataobject using the following supported fields available in EDD session:email(fromsession_data['user_email']orsession_data['user_info']['email'])phone_number(fromsession_data['user_info']['address']['phone'])address.first_name(fromsession_data['user_info']['first_name'])address.last_name(fromsession_data['user_info']['last_name'])address.street(fromsession_data['user_info']['address']['line1'])address.city(fromsession_data['user_info']['address']['city'])address.region(fromsession_data['user_info']['address']['state'])address.postal_code(fromsession_data['user_info']['address']['zip'])address.country(fromsession_data['user_info']['address']['country'])
In assets/js/event-providers/easy-digital-downloads.js:
- Preserve the existing
edd_cart_item_addedevent handling logic without modification. - Add Enhanced Conversions support for purchase event by:
- Extracting purchase data from
global._googlesitekit.edddata.purchaseif available. - Checking if the
gtagUserDatafeature flag is enabled usingglobal._googlesitekit?.gtagUserData. - Extracting the user data from the purchase object if present.
- Sending a
purchaseevent with the user data usinggtagEventwhen both the feature flag is enabled and user data is available.
- Extracting purchase data from
- Do not pass the
user_dataproperty if no valid user data is available. - Pass the
user_dataeven if it has only one supported field. - Complete the implementation based on the working POC in PR Enhancement/#11011 -[POC]Implement EC for EDD #11342.
Test Coverage
- Update existing EDD provider tests to verify the
get_event_namesmethod returns'add_to_cart'by default and conditionally includes'purchase'when thegtagUserDatafeature flag is enabled. - Add tests for the
get_enhanced_conversions_data_from_sessionmethod to verify it returns an empty array when the feature flag is disabled (can be tested without EDD dependencies).
QA Brief
- Set up Site Kit with Analytics/Ads and enable conversion tracking.
- Enable the
gtagUserDatafeature flag. - Set up Easy Digital Downloads
- Create a product with a price above 0
- Enable test mode by going to Downloads -> Payments -> enable Enable Test Mode and enable "Store gateway" in "Active Gateways"
- Go to Payments -> Checkout and enable all the fields in "Checkout Address Fields"
- Go to the product page, add it to the cart and go to the checkout page
- Using Tag Assistant, verify
purchaseevent is registered after completing the checkout, and itsdata_layerhas the following content :{ "address": { "first_name": "...", "last_name": "...", "street": "...", "city": "...", "region": "...", "postal_code": "...", "country": "..." }, "email": "...", "phone_number": "..." }
Changelog entry
- Add Enhanced Conversions support for Easy Digital Downloads 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