Skip to content

Add remaining GA event tracking for SFR phase 3 #12676

@techanvil

Description

@techanvil

Feature Description

Add GA event tracking for the Analytics account creation error notice and the new "Answer question" button in the Key Metrics settings panel.

The events to track are defined in the events sheet.


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

Acceptance criteria

The following GA events are tracked when their conditions are met:

Event Name Category Label Trigger Condition
analytics_account_creation_error {viewContext}_setup error code returned from the service element visibility user views the "Analytics account creation failed" error notice on the Analytics setup screen - ONLY initial setup (NOT module setup)
analytics_account_creation_error {viewContext} error code returned from the service element visibility user views the "Analytics account creation failed" error notice on the Analytics setup screen - ONLY module setup (NOT initial setup)
select_answer {viewContext}_kmw identifier of the question to answer click user clicks on "Answer question" for a question in the KM settings panel

Implementation Brief

  • Update assets/js/modules/analytics-4/components/common/AccountCreate/AnalyticsAccountCreationErrorNotice.tsx
    • Detect if we're in the initial setup flow by checking if the showProgress query arg is present
    • Get the current view context using useViewContext
    • Call trackEvent inside a useEffect with:
      • category: category: {viewContext}_setup if we're in initial setup, otherwise just viewContext
      • action: "analytics_account_creation_error"
      • label: errorCode (coming from the component's props)
  • Update assets/js/components/user-input/UserInputPreviewGroup/index.tsx
    • Get the current view context using useViewContext
    • Update the onClick prop of AnswerQuestionButton to include a call to trackEvent with:
      • category: category: {viewContext}_kmw
      • action: "select_answer"
      • label: slug (coming from the component's props)

Test Coverage

  • Add test coverage for the error notice in assets/js/modules/analytics-4/components/common/AccountCreate/AnalyticsAccountCreationErrorNotice.test.tsx
  • Add test coverage for the "Answer question" button event in assets/js/components/user-input/UserInputPreviewGroup.test.js

QA Brief

  • Use the Analytics Debugger Chrome extension.
  • Turn on the setupFlowRefresh feature flag.

During initial setup

  • Start the setup and go upto Set up Analytics step, add accountCreationErrorCode=testError query parameter in URL and refresh the page.
    • Notice that event analytics_account_creation_error is triggered with event category set to moduleSetup_setup and also the event_label as error code testError is passed.

Post setup completion

  • Complete the setup.
  • Start the analytics setup and come back till Connect Service - Analytics screen after initial auth.
  • Add accountCreationErrorCode=testError query parameter in URL and refresh the page.
    • Notice that event analytics_account_creation_error is triggered with event category set to moduleSetup and also the event_label as error code testError is passed.

Key Metrics Settings

  • Once setup is completed with Analytics connected, go to Site Kit > Settings > Admin Settings > Personalized metrics
  • Click Answer question CTA
  • Notice that event select_answer is triggered with event category set to settings_kmw and also the event_label as either postFrequency or goals.

Changelog entry

  • Add opt-in user tracking for the Analytics account creation error notice and the new "Answer question" button in the Key Metrics settings panel.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P0High priorityTeam MIssues for Squad 2Type: 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