Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Hide Site Goals widgets if corresponding event provider plugins are not installed #12765

Description

@jimmymadon

Feature Description

The Site Goals widgets are useful to tell a story of the entire funnel (form completion or product purchase). As such, these widgets are not helpful if we can't provide a tabbed breakdown of the "lead generation" and "purchase" events by Plugin source or Form titles. The breakdown can only be enabled if we are certain that Site Kit has the potential to track events (with a custom dimension for plugin source and form ID) for a site using the Plugin Conversion Reporting feature. So we should not enable the widget if a corresponding event provider plugin is not active. See this Design Doc section.


Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

  • If the Site Goals widget has not been rendered before (i.e. no events were detected initially), then the initial rendering of each widget should now also depend on their corresponding event provider plugin should be active.
    • For the Lead Generation widget to be shown: At least one of the “Lead generation” event provider plugins should be installed, viz. Contact Form 7, Mailchimp, Ninja Forms, Optin Monster, Popup Maker or WPForms.
    • For the Online Store Performance widget to be shown: At least one of the “E-commerce” event provider plugins should be active, viz. WooCommerce or Easy Digital Downloads.
  • In effect, the above widgets should not be rendered (and if both are not rendered, then the whole Site Goals widget area and navigation chip should be hidden) if the above conditions are not met.

Implementation Brief

  • In Conversion_Tracking, hook into googlesitekit_inline_base_data filter to provide active provider category flags

    • Follow the same pattern used by Consent_Mode which adds consentModeRegions via this filter
    • Add an inline_js_base_data method that receives the existing inline data array and appends two boolean values:
      • hasActiveLeadEventProviderstrue if any lead-category provider (Contact Form 7, WPForms, Ninja Forms, Mailchimp, OptinMonster, Popup Maker) is active
      • hasActiveEcommerceEventProviderstrue if any ecommerce-category provider (WooCommerce, Easy Digital Downloads) is active
    • Derive both by intersecting array_keys() of get_active_providers() against a hard-coded list of lead/ecommerce slugs from the respective provider classes' CONVERSION_EVENT_PROVIDER_SLUG constants
  • Update the CORE_SITE info.js datastore to consume the two new properties

    • In the getSiteInfo resolver, destructure hasActiveLeadEventProviders and hasActiveEcommerceEventProviders from global._googlesitekitBaseData and pass them through to receiveSiteInfo()
    • Add corresponding initial state entries (default false)
    • Expose via getSiteInfoProperty() selectors, following the pattern of existing boolean properties like isMultisite and webStoriesActive
  • Add isActive callbacks to both Site Goals widget registrations in the analytics-4 widgets index.js

    • For the analyticsOnlineStorePerformance widget, use the new CORE_SITE selector to check hasActiveEcommerceEventProviders
    • For the analyticsLeadGenerationPerformance widget, use the selector to check hasActiveLeadEventProviders
    • The existing widget visibility chain handles the rest automatically: when both widgets are inactive, isWidgetAreaActive returns false for the Site Goals area, isWidgetContextActive returns false, and the navigation chip is hidden via useVisibleSections
    • Note: the widgets already return WidgetNullComponent internally when no events are detected — the isActive callback provides an earlier gate at registration level so the widget/area/chip never render at all when the provider plugin is not installed

Test Coverage

  • Add tests for the new inline_js_base_data method on Conversion_Tracking - verify that the correct boolean flags are returned based on which provider plugins are active (mock the is_active() checks via defined constants)
  • Add tests for the new CORE_SITE selectors to verify they correctly surface values from site info state
  • Update widget registration tests to verify that isActive callbacks correctly gate the Site Goals widgets based on the CORE_SITE selector values

QA Brief

  • Setup SK with siteGoals feature flag
  1. Go to Tester Settings -> Analytics -> Conversion reporting
  2. Under detected events, choose ecommerce event, example purchase
  3. Install And Activate WooCommerce or Easy Digital Downloads plugin
  4. Verify that on Dashboard SIte Goals widget for ecommerce is showing
  5. Deactivate WooCommerce -> Verify site goals widget for ecommerce is not showing

  1. Repeat step 1 from previous use case, and choose contact event
  2. Install and activate any supported lead plugin, like Contact Form 7
  3. Verify that Site Goals widget for leads is showing in dashboard
  4. Deactivate the plugin -> Verify that leads widget is not showing in dashboard

Changelog entry

  • Update Site Goals widgets not to show up if no event provider plugins are activated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P0High priorityTeam SIssues for Squad 1Type: EnhancementImprovement of an existing feature

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions