Reading/Web/EventLogging best practices

Also see Reading/Web/Quantitative Testing and WMF-wide EventLogging best practices: Extension:EventLogging/Guide

Schemas

 * Schemas in MobileFrontend should be prefixed with
 * The talk page should be edited with the  template. For example Schema_talk:MobileWebSearch

Privacy
EventLogging data is subject to the Wikimedia Foundation's privacy policy and Data retention guidelines. In particular, sensitive data needs to be deleted after 90 days, in a purging process that (for EventLogging) is defined by a whitelist (of non-sensitive fields) for each schema.

The Analytics Engineering team offers some thoughts on best privacy practices for when writing schemas.

See the Audiences department's Instrumentation DACI regarding the general process for creating and reviewing schemas.

Sampling rate
See Reading/Web/Quantitative_Testing regarding terminology.

Be sure to check events for any newly deployed schema in its Grafana dashboard (linked on the talk page of the schema).

Consideration for experimental features in beta
If wanted you may want to consider a 100% sampling rate in beta. If so, please put this in the acceptance criteria for the task which implements the schema.

Use of tokens

 * See also Reading/Web/Quantitative_Testing

Some events need to be linkable to other events, for example Schema:Popups records several actions occurring within one pageview and within a session. This is usually done via a unique token that is generated once and used until the user closes the browser (session ID, cf. caveats), or moves to a new page (page token). See also T205569. If a schema records both session tokens and page names, one of them should be purged after 90 days.

Testing
EventLogging events can be monitored in the browser console (in the Network tab, filter for request URLs containing "event" or "beacon"). But a nicer display of events as MediaWiki notifications can be activated by applying the following code in the console, while being logged in: (See also T188640)

One may need to deactivate Do Not Track and browser extensions that might be blocking EventLogging requests (e.g. Privacy Badger).

Token mining
It may be necessary to mine a token (session, pageview, or otherwise) in order to test instrumentation consistently, for example during the QA step(s).

If an A/B test is implemented using the  function, then the following scripts will mine a token:


 * https://gist.github.com/phuedx/d580f01c501d207398828b717bf9870b