Skip to content

Add internal tracking for WP Pointer #11932

@jimmymadon

Description

@jimmymadon

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\Pointer to accept an optional tracking array with keys for view, dismiss, and click events (each with category, action, and optional label).
    • In Pointers::print_pointer_script(), when a pointer has tracking, add a data-tracking JSON payload to the inline script config.
  • 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 trackEvent utility to fire events.
    • Fires view when the pointer opens.
    • Fires click when the CTA (.googlesitekit-pointer-cta) is clicked.
    • Fires dismiss when the pointer is closed (either via the header dismiss icon or CTA with data-action="dismiss"), ensuring each event is sent only once per pointer.
  • Enqueue this script alongside wp-pointer in Pointers::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, pass config.tracking (if present) to the tracking helper so it can bind listeners and fire the view event.
  • Update Email_Reporting_Pointer and View_Only_Pointer to 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.php to 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_notification is tracked on load under correct category
  • Verify that dismiss and click are tracked correctly

Scenario 2

  • Setup Site Kit
  • Enable proactiveUserEngagement feature 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1Medium priorityTeam 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