-
Notifications
You must be signed in to change notification settings - Fork 318
Open
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
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 includes/Core/Conversion_Tracking/Conversion_Event_Providers/Easy_Digital_Downloads.php
:
- Update the
get_event_names
method to returnarray( 'add_to_cart' )
by default, and conditionally include'purchase'
only when thegtagUserData
feature flag is enabled. - Update the
register_hooks
method to:- Only register Enhanced Conversions hooks if the
gtagUserData
feature flag is enabled. - Add a
wp_footer
action that callsmaybe_add_purchase_data_from_session
to add purchase data on completion pages.
- Only register Enhanced Conversions hooks if the
- Add a
maybe_add_purchase_data_from_session
method 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_session
to 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_session
method that:- Calls
extract_user_data_from_session
to 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_session
method to extract customer data from EDD session data and normalize it using theEnhanced_Conversions
class methods. Do not hash the data. - Structure the
user_data
object 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_added
event handling logic without modification. - Add Enhanced Conversions support for purchase event by:
- Extracting purchase data from
global._googlesitekit.edddata.purchase
if available. - Checking if the
gtagUserData
feature flag is enabled usingglobal._googlesitekit?.gtagUserData
. - Extracting the user data from the purchase object if present.
- Sending a
purchase
event with the user data usinggtagEvent
when both the feature flag is enabled and user data is available.
- Extracting purchase data from
- Do not pass the
user_data
property if no valid user data is available. - Pass the
user_data
even 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_names
method returns'add_to_cart'
by default and conditionally includes'purchase'
when thegtagUserData
feature flag is enabled. - Add tests for the
get_enhanced_conversions_data_from_session
method 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
gtagUserData
feature 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
purchase
event is registered after completing the checkout, and itsdata_layer
has the following content :{ "address": { "first_name": "...", "last_name": "...", "street": "...", "city": "...", "region": "...", "postal_code": "...", "country": "..." }, "email": "...", "phone_number": "..." }
Changelog entry
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