-
Notifications
You must be signed in to change notification settings - Fork 328
Description
Feature Description
Site Kit currently uses two WP pointers that point to the Site Kit plugin link in the WP Admin menu - one for introducing users to the availability of dashboard sharing/view-only dashboard and another for the introduction of Email Reporting. As part of the PUE epic, we want to add internal GA tracking events for when users view or interact with the pointer.
This issue was explored within #11168. However, the trackEvent call isn't readily available as mentioned in that issue's IB within the simple JavaScript block. So this issue will re-tackle the adding of GA tracking events to both of our existing pointers in a reusable manner.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- The WP Pointer implementation is updated to track analytics events for key events, view, dismiss and click, in a reusable way (not specific to the Email Reporting pointer)
- All 6 "WP Pointer" events within this spreadsheet are tracked as per the category and actions defined therein.
Implementation Brief
- Extend
Google\Site_Kit\Core\Admin\Pointerto accept an optional tracking array with keys forview,dismiss, andclickevents (each withcategory,action, and optionallabel).- In
Pointers::print_pointer_script(), when a pointer has tracking, add adata-trackingJSON payload to the inline script config.
- In
- Add a small admin script (e.g.,
assets/js/googlesitekit-admin-pointers-tracking.js, built via existing tooling) that:- Exposes a function to register tracking for a pointer given its config.
- Uses the existing
trackEventutility to fire events. - Fires
viewwhen the pointer opens. - Fires
clickwhen the CTA (.googlesitekit-pointer-cta) is clicked. - Fires
dismisswhen the pointer is closed (either via the header dismiss icon or CTA withdata-action="dismiss"), ensuring each event is sent only once per pointer.
- Enqueue this script alongside
wp-pointerinPointers::enqueue_pointers()and have the inline pointer script call the tracking helper when tracking data is present. - In the inline script generated by
print_pointer_script(), after initializing the pointer, passconfig.tracking(if present) to the tracking helper so it can bind listeners and fire the view event. - Update
Email_Reporting_PointerandView_Only_Pointerto include the tracking metadata per the spreadsheet (6 events total across both pointers; set category/actions per sheet).
Test Coverage
- Add test to the
tests/phpunit/integration/Core/Admin/PointerTest.phpto confirm pointers include tracking config in the inline script data when defined.
QA Brief
Scenario 1
- Setup Site Kit
- Share a dashboard with another role
- Log-in with that role - you will see View only pointer
- Verify that
view_notificationis tracked on load under correct category - Verify that dismiss and click are tracked correctly
Scenario 2
- Setup Site Kit
- Enable
proactiveUserEngagementfeature flag- Ensure you are not already subscribed to the Email Reporting
- Go to main WP dashboard page - you will see Email reporting pointer
- Like in scenario 1 verify that tracking for view, dismiss and click is working with correct category
Note
After dismissing the pointer, you can re-surface it by going to the wp_usermeta and clean dismissed_wp_pointers column. Also wp_googlesitekitpersistent_dismissed_items - this one is needed for email reporting pointer
Changelog entry
- Add internal tracking for WP Pointer.