Page MenuHomePhabricator

Finish wiring up search recommendations A/B test click tracking
Closed, ResolvedPublic5 Estimated Story Points

Description

Background

As follow up to T382080, and after T383611 is completed, we need to finish the click tracking according to the spec: https://docs.google.com/spreadsheets/d/1tYYRsxICotHT_uAt0gfZckHNZBmqZTKuykeUEwQSCvs/edit?gid=0#gid=0

User story

  • As the web team we want to understand how search recommendations impacts search sessions in general

Requirements

Click tracking is implemented for all the click tracking metrics in the spec document:

Search sessions initiationsThe empty search box appearsproduct_metrics.web_base.search_ab_test_clicks (TBD) action='init', action_subtype='init_search_box'
Actions of clicking the empty search boxThe users clicked the empty search box, indicating that those in experiment group would have seen the new empty-state suggestions.product_metrics.web_base.search_ab_test_clicks (TBD) action='click', action_source='search_box'
Impressions of the empty-state recommendationsThe list of the empty-state recommendations appearsproduct_metrics.web_base.search_ab_test_clicks (TBD) action='show', action_subtype='show_empty_state_recommendation'
Actions of entering the first letterThe users start typing the first letter, indicating that they have completed using the empty search recommendation product_metrics.web_base.search_ab_test_clicks(TBD) action='type', action_source='search_box'
Impressions of the type-ahead search recommendationsThe list of the type-ahead recommendations appearsproduct_metrics.web_base.search_ab_test_clicks (TBD) action='show', action_subtype='show_autocomplete_recommendation'
Action of clicking the empty-state recomendationsClicks to one of the recommendations from the new empty-state suggestionsproduct_metrics.web_base.search_ab_test_clicks (TBD) action='click', action_source='empty_search_suggestion'
Action of clicking the type-ahead search recomendationsClicks to one of the search recommendations from the type-ahead search suggestionsproduct_metrics.web_base.search_ab_test_clicks (TBD) action='click', 'autocomplete_search_suggestion'

BDD

Feature: Search Recommendations Click Tracking  
  Scenario: Track search session initiation  
    Given a user is on a Wikimedia search page  
    When the empty search box appears  
    Then an event with action 'init' and action_subtype 'init_search_box' should be fired  

  Scenario: Track clicking on the empty search box  
    Given a user is on a Wikimedia search page  
    When the user clicks inside the empty search box  
    Then an event with action 'click' and action_source 'search_box' should be fired  

  Scenario: Track impressions of empty-state recommendations  
    Given a user is on a Wikimedia search page  
    When the list of empty-state recommendations appears  
    Then an event with action 'show' and action_subtype 'show_empty_state_recommendation' should be fired  

  Scenario: Track when user starts typing  
    Given a user is on a Wikimedia search page  
    When the user types the first letter into the search box  
    Then an event with action 'type' and action_source 'search_box' should be fired  

  Scenario: Track impressions of type-ahead search recommendations  
    Given a user is on a Wikimedia search page  
    When type-ahead recommendations appear  
    Then an event with action 'show' and action_subtype 'show_autocomplete_recommendation' should be fired  

  Scenario: Track clicks on empty-state recommendations  
    Given a user is on a Wikimedia search page  
    When the user clicks on an empty-state recommendation  
    Then an event with action 'click' and action_source 'empty_search_suggestion' should be fired  

  Scenario: Track clicks on type-ahead recommendations  
    Given a user is on a Wikimedia search page  
    When the user clicks on a type-ahead recommendation  
    Then an event with action 'click' and action_source 'autocomplete_search_suggestion' should be fired

Test Steps

Test Case 1: Verify event fires for search session initiation

  1. Open an incognito window and visit https://en.m.wikipedia.beta.wmflabs.org/w/index.php?title=T352930.
  2. Log in to a user account.
  3. Open the JavaScript console and execute:
mw.loader.using('mediawiki.api').then(function () {  
  new mw.Api().saveOption('eventlogging-display-console', '1');  
});
  1. Ensure the search bar is visible.
  2. Click on the empty search box.
  3. Verify that an event fires with:

• Event Name: product_metrics.web_base.search_ab_test_clicks
• Action: init
• Action Subtype: init_search_box

  1. AC1: Event fires when the empty search box appears.

Test Case 2: Verify event fires when user clicks on the empty search box

  1. Follow Test Case 1 steps until step 4.
  2. Click inside the search box.
  3. Verify that an event fires with:

• Event Name: product_metrics.web_base.search_ab_test_clicks
• Action: click
• Action Source: search_box

  1. AC2: Event fires when the user clicks on the empty search box.

Test Case 3: Verify event fires when empty-state recommendations appear

  1. Follow Test Case 1 steps until step 4.
  2. Ensure that the empty-state recommendations appear in the search box dropdown.
  3. Verify that an event fires with:

• Event Name: product_metrics.web_base.search_ab_test_clicks
• Action: show
• Action Subtype: show_empty_state_recommendation

  1. AC3: Event fires when empty-state recommendations appear.

Test Case 4: Verify event fires when user starts typing the first letter

  1. Follow Test Case 1 steps until step 4.
  2. Type a single letter in the search box.
  3. Verify that an event fires with:

• Event Name: product_metrics.web_base.search_ab_test_clicks
• Action: type
• Action Source: search_box

  1. AC4: Event fires when user types the first letter.

Test Case 5: Verify event fires when type-ahead recommendations appear

  1. Follow Test Case 4 steps until step 2.
  2. Ensure that type-ahead recommendations appear in the search box dropdown.
  3. Verify that an event fires with:

• Event Name: product_metrics.web_base.search_ab_test_clicks
• Action: show
• Action Subtype: show_autocomplete_recommendation

  1. AC5: Event fires when type-ahead recommendations appear.

Test Case 6: Verify event fires when user clicks on an empty-state recommendation

  1. Follow Test Case 3 steps until step 2.
  2. Click on one of the empty-state recommendations.
  3. Verify that an event fires with:

• Event Name: product_metrics.web_base.search_ab_test_clicks
• Action: click
• Action Source: empty_search_suggestion

  1. AC6: Event fires when user clicks on an empty-state recommendation.

Test Case 7: Verify event fires when user clicks on a type-ahead recommendation

  1. Follow Test Case 5 steps until step 2.
  2. Click on one of the type-ahead recommendations.
  3. Verify that an event fires with:

• Event Name: product_metrics.web_base.search_ab_test_clicks
• Action: click
• Action Source: autocomplete_search_suggestion

  1. AC7: Event fires when user clicks on a type-ahead recommendation.

Acceptance criteria

  • Spec is updated and QAed

Event Timeline

Jdlrobson changed the task status from Open to In Progress.Jan 10 2025, 1:06 AM
Jdlrobson assigned this task to bwang.
bwang renamed this task from Finish implementing search recommendations A/B test click tracking, add search session id to events to Finish implementing rest of search recommendations A/B test click tracking.Jan 13 2025, 5:43 PM
bwang updated the task description. (Show Details)
bwang updated the task description. (Show Details)
bwang renamed this task from Finish implementing rest of search recommendations A/B test click tracking to Finish implementing search recommendations A/B test click tracking with new A/B instrumentation.Jan 13 2025, 5:58 PM
bwang renamed this task from Finish implementing search recommendations A/B test click tracking with new A/B instrumentation to Finish implementing search recommendations A/B test click tracking.Jan 13 2025, 7:23 PM
bwang updated the task description. (Show Details)
Jdlrobson set the point value for this task to 5.Jan 14 2025, 5:18 PM
bwang renamed this task from Finish implementing search recommendations A/B test click tracking to Finish wiring up search recommendations A/B test click tracking.Jan 14 2025, 6:06 PM
bwang removed bwang as the assignee of this task.Jan 14 2025, 6:11 PM
Jdlrobson lowered the priority of this task from High to Medium.Jan 15 2025, 10:29 PM

The users start typing the first letter, indicating that they have completed using the empty search recommendation mediawiki_web_ui_actions

Are we only interested in the first letter, or any query being run?

Note the following scenario:

  • User sees empty search recommendations
  • User types "C", "a", "t"
  • A search occurs and displays some search results. Empty search recommendations clear.
  • User hits backspace 3 times
  • User sees empty search recommendations

Change #1111719 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/extensions/MobileFrontend@master] WIP: Search: Add mw.hooks at certain events

https://gerrit.wikimedia.org/r/1111719

Change #1111721 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/extensions/RelatedArticles@master] WIP: Render: Fire hook on clicking related articles

https://gerrit.wikimedia.org/r/1111721

Change #1111722 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/extensions/WikimediaEvents@master] WIP: Instrument empty search experiment

https://gerrit.wikimedia.org/r/1111722

Jdlrobson-WMF raised the priority of this task from Medium to High.Jan 22 2025, 5:05 PM

Change #1111719 merged by jenkins-bot:

[mediawiki/extensions/MobileFrontend@master] Search: Add ext.MobileFrontend.searchOverlay.click hook for click events

https://gerrit.wikimedia.org/r/1111719

Change #1111721 merged by jenkins-bot:

[mediawiki/extensions/RelatedArticles@master] Render: Fire hook on clicking related articles

https://gerrit.wikimedia.org/r/1111721

Change #1111722 merged by jenkins-bot:

[mediawiki/extensions/WikimediaEvents@master] Instrument empty search experiment

https://gerrit.wikimedia.org/r/1111722

Jdlrobson-WMF subscribed.

In terms of QA, for now we just want to verify that events are firing at different per the requirements on https://en.m.wikipedia.beta.wmflabs.org/w/index.php?title=T352930 when bucketed and when not bucketed (you have a 50% chance in an incognito window of either bucket).

You can surface events as a logged in user using the following code:

Please note the code might take some time to show up on beta cluster (hopefully will be there by 4 PST) to ensure the latest code is running on beta cluster.

mw.loader.using( 'mediawiki.api' ).then( function () {
  new mw.Api().saveOption( 'eventlogging-display-console', '1' );
} );

Change #1114033 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/extensions/WikimediaEvents@master] Be more flexible with experiment name

https://gerrit.wikimedia.org/r/1114033

Change #1114033 merged by jenkins-bot:

[mediawiki/extensions/WikimediaEvents@master] Be more flexible with experiment name

https://gerrit.wikimedia.org/r/1114033

Edtadros subscribed.

Status: ❌ FAIL
Environment: Beta
OS: macOS
Browser: Chrome
Device: MS

Test Steps

Test Case 1: Verify event fires for search session initiation

  1. Open an incognito window and visit https://en.m.wikipedia.beta.wmflabs.org/w/index.php?title=T352930.
  2. Log in to a user account.
  3. Open the JavaScript console and execute:
mw.loader.using('mediawiki.api').then(function () {  
  new mw.Api().saveOption('eventlogging-display-console', '1');  
});
  1. Ensure the search bar is visible.
  2. Click on the empty search box.
  3. Verify that an event fires with:

• Event Name: mediawiki_web_ui_actions
• Action: init
• Action Subtype: init_search_box

  1. AC1: Event fires when the empty search box appears.

screenshot 149.png (1,131×619 px, 151 KB)

{
    "action": "init",
    "font": "1",
    "is_full_width": false,
    "is_page_preview_on": true,
    "is_pinned": false,
    "is_media_viewer_enabled": true,
    "is_dark_mode_prepared_by_os": true,
    "dark_mode_setting": "0",
    "is_dark_mode_on": false,
    "action_context": "stable,amc",
    "viewport_size_bucket": "1000px-1199px",
    "action_source": "ns=0",
    "is_temp": false,
    "$schema": "/analytics/mediawiki/product_metrics/web_ui_actions/1.0.2",
    "page": {
        "namespace_id": 0
    },
    "performer": {
        "is_logged_in": true,
        "session_id": "74437b37345eed485156",
        "pageview_id": "97c1084208c94e4b5c03",
        "edit_count_bucket": "5-99 edits",
        "groups": [
            "*",
            "user",
            "autoconfirmed"
        ],
        "is_bot": false
    },
    "mediawiki": {
        "skin": "minerva",
        "database": "enwiki"
    },
    "agent": {
        "client_platform": "mediawiki_js",
        "client_platform_family": "mobile_browser"
    },
    "sample": {
        "rate": 1,
        "unit": "session"
    },
    "dt": "2025-01-30T01:35:59.206Z",
    "meta": {
        "stream": "mediawiki.web_ui_actions",
        "domain": "en.wikipedia.beta.wmflabs.org"
    }
}

Test Case 2: Verify event fires when user clicks on the empty search box

  1. Follow Test Case 1 steps until step 4.
  2. Click inside the search box.
  3. Verify that an event fires with:

• Event Name: mediawiki_web_ui_actions
• Action: click
• Action Source: search_box

  1. AC2: Event fires when the user clicks on the empty search box.

No action=click event fires when I click the search box

Test Case 3: Verify event fires when empty-state recommendations appear

  1. Follow Test Case 1 steps until step 4.
  2. Ensure that the empty-state recommendations appear in the search box dropdown.
  3. Verify that an event fires with:

• Event Name: mediawiki_web_ui_actions
• Action: show
• Action Subtype: show_empty_state_recommendation

  1. AC3: Event fires when empty-state recommendations appear.

No action=show appears, or any new event appears.

Test Case 4: Verify event fires when user starts typing the first letter

  1. Follow Test Case 1 steps until step 4.
  2. Type a single letter in the search box.
  3. Verify that an event fires with:

• Event Name: mediawiki_web_ui_actions
• Action: type
• Action Source: search_box

  1. AC4: Event fires when user types the first letter.

No action=type or any other event appears

Test Case 5: Verify event fires when type-ahead recommendations appear

  1. Follow Test Case 4 steps until step 2.
  2. Ensure that type-ahead recommendations appear in the search box dropdown.
  3. Verify that an event fires with:

• Event Name: mediawiki_web_ui_actions
• Action: show
• Action Subtype: show_autocomplete_recommendation

  1. AC5: Event fires when type-ahead recommendations appear.

No action=show or any other event appears

Test Case 6: Verify event fires when user clicks on an empty-state recommendation

  1. Follow Test Case 3 steps until step 2.
  2. Click on one of the empty-state recommendations.
  3. Verify that an event fires with:

• Event Name: mediawiki_web_ui_actions
• Action: click
• Action Source: empty_search_suggestion

  1. AC6: Event fires when user clicks on an empty-state recommendation.

No action=click event appears

Test Case 7: Verify event fires when user clicks on a type-ahead recommendation

  1. Follow Test Case 5 steps until step 2.
  2. Click on one of the type-ahead recommendations.
  3. Verify that an event fires with:

• Event Name: mediawiki_web_ui_actions
• Action: click
• Action Source: autocomplete_search_suggestion

  1. AC7: Event fires when user clicks on a type-ahead recommendation.

No action=click event appears

@Jdlrobson-WMF , in general only the action=init event is appearing.

Jdlrobson-WMF updated the task description. (Show Details)

The init event is also a fail as we're looking for events to product_metrics.web_base.search_ab_test_clicks not mediawiki_web_ui_actions (have updated description to make that clearer)
The issue here is the configuration on beta cluster is wrong. We'll fix that next week and repeat QA as part of T385309.