Skip to content

Implement Easy Digital Downloads integration #11011

@hussain-t

Description

@hussain-t

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 return array( 'add_to_cart' ) by default, and conditionally include 'purchase' only when the gtagUserData 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 calls maybe_add_purchase_data_from_session to add purchase data on completion pages.
  • 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.
  • 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.
  • Add an extract_user_data_from_session method to extract customer data from EDD session data and normalize it using the Enhanced_Conversions class methods. Do not hash the data.
  • Structure the user_data object using the following supported fields available in EDD session:
    • email (from session_data['user_email'] or session_data['user_info']['email'])
    • phone_number (from session_data['user_info']['address']['phone'])
    • address.first_name (from session_data['user_info']['first_name'])
    • address.last_name (from session_data['user_info']['last_name'])
    • address.street (from session_data['user_info']['address']['line1'])
    • address.city (from session_data['user_info']['address']['city'])
    • address.region (from session_data['user_info']['address']['state'])
    • address.postal_code (from session_data['user_info']['address']['zip'])
    • address.country (from session_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 using global._googlesitekit?.gtagUserData.
    • Extracting the user data from the purchase object if present.
    • Sending a purchase event with the user data using gtagEvent when both the feature flag is enabled and user data is available.
  • 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 the gtagUserData 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 its data_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 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