Page MenuHomePhabricator

Instrument clicks to links in the Languages list in the sidebar
Open, HighPublic3 Estimated Story Points

Description

Readers Web will be A/B testing the existing treatment of the language switcher and a new treatment being worked on as part of Desktop Improvements. Those users in the control group will be sent the existing treatment.

Per T268504, we'd like to know how many users are clicking on links in the Languages list in the sidebar. In https://phabricator.wikimedia.org/T268504#6796216, we explored measuring this and landed on adding this functionality to the UniversalLanguageSwitcher instrument.

AC

  • When I click on a link in the Languages list in the sidebar, then I see a UniversalLanguageSwitcher event being logged
    1. The event's context property is set to languages-list; and
    2. The event's language property is set to the language code of the wiki being linked to, i.e. the hreflang attribute of the link

QA Steps

  • Navigate to https://en.wikipedia.org/wiki/Main_Page
  • Click on any link in the Languages list
  • Observe that an UniversalLanguageSwitcher event is logged with the properties described above
  • Wait for navigation to finish
  • Click on any link in the Languages list
  • Again, observe that an UniversalLanguageSwitcher event is logged with the properties described above

Developer Notes

WikimediaEvents/modules/ext.wikimediaEvents/universalLanguageSelector.js
function interfaceLanguageChange( language, source ) {
  log( {
    /* ... */
    language: language,
    context: source || 'interface'
  } );
}

/* ... */

document.body.addEventListener( 'click', ( event ) => {
  var el = event.target;
  if ( !el.classList.contains( 'interlanguage-link-target' ) ) {
    return;
  }

  mw.hook( 'mw.uls.interface.language.change' ).fire(
    el.attributes.getNamedItem( 'hreflang' ),
    'languages-list'
  );
} );

Event Timeline

Jdlrobson added a subscriber: Jdlrobson.

The WikimediaEvents extension now hosts this code.

While estimating today, we decided we need to clarify with Megan if we are only tracking number of clicks or do we also need to know the number of users clicking the links (and therefore a user identifier becomes important)

While estimating today, we decided we need to clarify with Megan if we are only tracking number of clicks or do we also need to know the number of users clicking the links (and therefore a user identifier becomes important)

hi @MNeisler - per Nick's comment, do number of users clicking or just total clicks need to be tracked for this instrumentation?

@cjming - Thanks for the ping! If possible, it would be useful to have a user identifier to track the number of users. This will help us understand the frequency of usage across users (i.e. Is it just a few users clicking it frequently or a number of users clicking it once?)

Change 681422 had a related patch set uploaded (by Clare Ming; author: Clare Ming):

[mediawiki/extensions/WikimediaEvents@master] Add language switching event logging for legacy sidebar.

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

cjming added a subscriber: cjming.

hi @MNeisler - associated patch should be approved/merged shortly. After some discussion with @nray, it appears that the web_session_id for authenticated users persists between opening/quitting tabs within a browser. However when a browser is quit/reopened, a new web_session_id is generated. Let us know if this is problematic for tracking user clicks appropriately - hopefully not.