Extension:QuickSurveys/de-formal

The QuickSurveys extension displays in-article banners, through which users can be canvassed for their feedback.

Documentation and features

 * Rationale
 * Deploying surveys
 * Documentation on metawiki

As of 2021, QuickSurveys can:


 * target random readers
 * target readers of a specific page
 * target based on whether you're logged-in/logged-out
 * target based on edit bucket
 * target based on user agent
 * ask one multiple-choice question
 * collect one or more responses to that question ("pick the best answer" vs. "check all that apply")
 * offer a link to another page (e.g., to provide information about a longer survey)
 * embed one or more surveys at a customizable location on a specific page

Known problems:


 * Some ad-blocking and no-script software blocks this extension.
 * Setting up a survey requires support from a developer.
 * Reading survey results requires support from analytics or a developer.
 * No ability to target users in an arbitrary workflow or condition.

Prerequisites
Until version 1.38, QuickSurveys depends on EventLogging and won't work without it. In 1.39 the installation of EventLogging is optional. It is required for internal surveys and for tracking survey impressions.

Configuration
Here are configurations for the two major types of survey: an "internal survey" which displays a question and a set of possible answers in the article itself, and an "external survey" which links to another platform (e.g. Google Forms).

Defining an audience
It is possible to define audiences for a survey based edit count, whether a respondent is logged in, user registration date, and their country (based on IP).

The audience field is optional and can be omitted if you want the survey to show to everyone (as defined in coverage). You can also only include some of the parameters. For example, including just  will target users who have at least that many edits with no maximum.

Note, the audience is not included in sampling, so for example if coverage is 0.5, 50% of all users will be bucketed for the survey, but only the users in that 50% that match the audience will actually see the survey.

All audience keys are additive.

We will accept several keys:


 * minEdits: the minimum number of edits a user should have
 * maxEdits: the maximum number of edits a user should have
 * anons: is the survey targeted to anons (true) or logged-in (false) only? If undefined, both groups will potentially be included.
 * registrationStart: if the survey is targeted by registration date, user had to join on or after this date. Date is in format YYYY-MM-DD
 * registrationEnd: if the survey is targeted by registration date, user had to join before or on this date. Date is in format YYYY-MM-DD
 * countries: a list of two letter country codes that are matched against window.Geo.country
 * pageIds: a list of article IDs, the survey can only be displayed on matching pages

Survey layout
The following configuration fields control how the survey will be displayed:


 * type: external - The survey is hosted on an external website, all we show is a link.QuickSurveys "external" mode.png
 * layout: single-answer - Choices are each presented as a button. Clicking a choice will immediately submit and dismiss the survey, unless a freeform text input is enabled.Single-answer QuickSurveys survey.png
 * layout: multiple-answer - Choices are each presented as a checkbox. Multiple choices can be selected.  A freeform text input will not be provided.Multiple-answer QuickSurveys survey.png
 * freeformTextLabel - The respondent is prompted to enter freeform text, in addition to an optional choice of answer.Freeform text in QuickSurveys.png
 * shuffleAnswersDisplay - The answers will be randomized and displayed in a different order for each respondent. This helps average out a response bias caused by the order of answers.  Defaults to true.
 * embedElementId - When this field is present, the survey can only be injected into a page with a DOM element matching the configured value by ID. For example, a survey with   will be displayed on a page with HTML , immediately after that element.QuickSurveys embedded survey.png

Adding message keys
Messages can be defined as part of an extension e.g. WikimediaMessages or by wiki page. For example the message "ext-quicksurveys-example-internal-survey-answer-positive" can be defined by editing the wiki page MediaWiki:ext-quicksurveys-example-internal-survey-answer-positive

For editing messages ensure you have the right permissions. You will need edit-interface right.

How to load a specific survey
You can bypass the sampling and load a survey using one of the methods below. Please note that the survey you want to load needs to be enabled and passed to the front end. See the "Notes and Gotchas" section if you are having trouble seeing a survey.


 * To load any of the available surveys append  to the URL;
 * To load a survey whose name is 'surveyname' append  to the URL.


 * The following prefixes are deprecated but may be useful:
 * To load an internal survey whose name is 'internal example survey' append  to the URL;
 * To load an external survey whose name is 'external example survey' append  to the URL.

Additionally, QuickSurveys has a JavaScript API that you can use to load a survey, e.g. the following loads a survey whose name is 'surveyname':

Note well that this will work on any page.

Rules for displaying a survey
Much of this logic seems to reside on the client.

To see what surveys are available you'll need to inspect the source code of JavaScript of the ext.quicksurveys.lib module. For example on the beta cluster: https://en.wikipedia.beta.wmflabs.org/w/load.php?modules=ext.quicksurveys.lib&debug=true (look for resources/ext.quicksurveys.lib/surveyData.json)

Results
The initial impressions and responses are recorded in EventLogging. Initial impressions are in the QuickSurveyInitiation schema and responses are in QuickSurveysResponses. The  field in both schemas corresponds to the survey's configured.

Troubleshooting
For local development using Docker, to see quick surveys rendered on an article page, the page must exist locally when using Content Provider. Once the local page is created, appending the appropriate query parameters to the url will make the quick survey visible.

Surveys are not showing
You can see which surveys are available by looking at the source of the ext.quicksurveys.lib module e.g. https://en.wikipedia.beta.wmflabs.org/w/load.php?modules=ext.quicksurveys.lib&debug=true&only=scripts

Available surveys will be listed in resources/ext.quicksurveys.lib/surveyData.json. If your survey is not shown then there is likely a problem with your configuration change. Inspect carefully for typos.

Notes and Gotchas

 * is provided by CentralNotice. To avoid setting up an extension run  in production and add   to your code.

Note that a survey won't show up when:


 * on the Main Page;
 * on non-article page;
 * on non-existent article page. Be careful when using the MobileFrontend content provider!;
 * on skin Minerva when the beta opt in panel is shown;
 * (Broken: if a survey is an external one and points to non-https location. TODO: Pending .)

Live example surveys

 * Beta cluster - Internal example survey
 * Beta cluster - Internal example survey with description and freeform text
 * Beta cluster - Internal multiple answer example survey
 * Beta cluster - Internal multiple answer example survey with description and freeform text
 * Beta cluster - External example survey

Survey Deployment Notes

 * Useful information about deploying surveys to beta and production.


 * Adding new survey messages (such as new questions) to WikiMediaMessages is an involved process:
 * Messages need to be added to  and documented in
 * Time should be allowed for and efforts coordinated for those messages to be localized in translatewiki as appropriate/necessary for the community of a given project
 * These messages translations must be pushed from translatewiki back to WikiMediaMessages and deployed to a project before those messages are available for display in a survey


 * QA of surveys is an involved process, requiring editing of the media-wiki config repository.
 * Patchdemo can't be used for checking new surveys because surveys are configuration, and patchdemo is not configurable. Patchdemo may only be used for QA of ui/code changes, not surveys themselves.
 * The beta cluster is the only persistent environment available to QA survey content.
 * Surveys being tested on beta with a high coverage should be limited to pageids, such as user sandboxes.
 * Because beta inherits configuration from production, you should check to see if the extension is enabled on production by checking for the beta wikiname in the  array in   If it is not, you will need to add it to


 * Surveys are deployed to production as backports, since they are configuration changes:
 * Please see the deployment calendar for details on backport windows.
 * During the backport window deployment, you will need to verify the change was deployed successfully using a mwdebug host.
 * Audience/coverage settings can greatly impact the ability of a survey to display without forcing them. For example, based on the audience/coverage settings you may have to create an account on the test project and have the necessary edit count to trigger a survey.
 * Be prepared to discuss your phabricator ticket about coverage and audience since the display of the survey has an impact on the user experience. Deployers may decline any patch if they don't understand the impact. Bring a friend to your first deployment.