-
Notifications
You must be signed in to change notification settings - Fork 330
Description
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
bodyof the request to thesite-management/features/endpoint:audseg_setup_completed (bool?): Setup completed statusaudseg_audience_count (num?): Number ofavailableAudiencesanalytics_adsense_linked (bool?): Analyticssettings.adSenseLinkedshared_modules (string[]): List of connected + modules shared with any rolerrm_publication_onboarding_state (enum?): One ofONBOARDING_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.phpandincludes/Modules/Reader_Revenue_Manager.php:- Let these classes implement the
Provides_Feature_Metricsinterface. - 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: Inincludes/Core/Modules/Modules.php, create a method,list_shared_modules(). Use theget_connected_modulesandget_module_sharing_settingsmethods 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.
- For
- Let these classes use the
Feature_Metrics_Traitand within each of theirregister()methods, call theregister_feature_metrics()method defined in the trait.
- Let these classes implement the
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_featuresrow from thewp_optionstable. - Ensure Site Kit is running in the browser so that the
admin-ajaxscript is running every 2 minutes. - Use a Proxy request inspector like Proxyman or mitmproxy to inspect outbound requests to the
site-management/featuresendpoint. - Repeat the above 3 steps to verify that each of the fields mentioned in the AC are correctly added to the
feature_metricsarray 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.