Skip to content

Track Feature Metrics for Audience Segmentation, AdSense reporting, Dashboard Sharing and RRM #11421

@jimmymadon

Description

@jimmymadon

Feature Description

In order to understand better how users engage with Site Kit, we have planned to track a few more site-wide Internal Metrics. These metrics are completely separate and in addition to the Google Analytics events that we track for users that have enabled GA tracking for Site Kit.

Issue #11316 creates the infrastructure / hook to collect and send metrics to the Site Kit proxy service as part of the site-management/features/ request which is made on Site Kit setup and then twice daily via a cronjob (its main purpose being to enable/disable features that are gated by feature flags for Site Kit users).

This issue will add metrics pertaining to Audience Segmentation, AdSense reporting, Dashboard Sharing and RRM as per this document.


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

Acceptance criteria

  • Using the infrastructure created in Track feature metrics for Ads PAX and GTG #11316, the following additional metrics should be tracked via sending data in the body of the request to the site-management/features/ endpoint:
    • audseg_setup_completed (bool?): Setup completed status
    • audseg_audience_count (num?): Number of availableAudiences
    • analytics_adsense_linked (bool?): Analytics settings.adSenseLinked
    • shared_modules (string[]): List of connected + modules shared with any role
    • rrm_publication_onboarding_state (enum?): One of ONBOARDING_COMPLETE, ONBOARDING_ACTION_REQUIRED, PENDING_VERIFICATION, UNSPECIFIED

Implementation Brief

  • In includes/Core/User/Audience_Segmentation.php, includes/Modules/Analytics_4.php, includes/Core/Modules/Modules.php and includes/Modules/Reader_Revenue_Manager.php:
    • Let these classes implement the Provides_Feature_Metrics interface.
    • Create a get_feature_metrics() method in each of these classes that should return an array of corresponding fields as per the AC.
      • For shared_modules: In includes/Core/Modules/Modules.php, create a method, list_shared_modules(). Use the get_connected_modules and get_module_sharing_settings methods and identify the modules that are connected AND have a shared role.
      • The remaining data is readily available in the corresponding settings classes for each of these features.
    • Let these classes use the Feature_Metrics_Trait and within each of their register() methods, call the register_feature_metrics() method defined in the trait.

Test Coverage

  • Use PHPUnit to test each of the methods being created to track the new feature metrics.

QA Brief

  • Smoke test Plugin setup, connecting Analytics, setting up Audience Segmentation, AdSense and RRM modules.

QA: Eng alongside Code review

  • Delete the googlesitekitpersistent_remote_features row from the wp_options table.
  • Ensure Site Kit is running in the browser so that the admin-ajax script is running every 2 minutes.
  • Use a Proxy request inspector like Proxyman or mitmproxy to inspect outbound requests to the site-management/features endpoint.
  • Repeat the above 3 steps to verify that each of the fields mentioned in the AC are correctly added to the feature_metrics array in the request, both, before and after setting up Audience Segmentation, AdSense (and having an account linked to Analytics), RRM and sharing some modules using dashboard sharing popup.
  • The body of the request above should be along the lines of:
{
  "platform": "wordpress/google-site-kit",
  "version": "1.162.0",
  "platform_version": "6.8.2",
  "php_version": "8.4.10",
  "user_count": 3,
  "connectable_user_count": 2,
  "connected_user_count": 1,
  "active_modules": "site-verification search-console ads analytics-4 pagespeed-insights reader-revenue-manager",
  "connected_modules": "site-verification search-console ads analytics-4 pagespeed-insights",
  "feature_metrics": {
      "shared_modules": [
          "search-console",
          "pagespeed-insights"
      ],
      "ads_connection": "manual",
      "audseg_setup_completed": true,
      "audseg_audience_count": 4,
      "analytics_adsense_linked": false,
      "rrm_publication_onboarding_state": ""
  }
}

Changelog entry

  • Implement Audience Segmentation, AdSense reporting, Dashboard Sharing and RRM feature metrics tracking.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Low priorityQA: EngRequires specialized QA by an engineerTeam SIssues for Squad 1Type: 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