Extension:LandingCheck
LandingCheck Release status: stable |
|
---|---|
Implementation | Special page |
Description | Send users to localized landing pages with fallback options |
Author(s) | Ryan Kaldari |
Latest version | 2.1 |
MediaWiki | >= 1.42 |
License | GNU General Public License 2.0 or later |
Download | |
|
|
Quarterly downloads | Lua error in Module:Extension at line 172: bad argument #1 to 'inNamespace' (unrecognized namespace name 'skin'). |
Public wikis using | Lua error in Module:Extension at line 172: bad argument #1 to 'inNamespace' (unrecognized namespace name 'skin'). |
Translate the LandingCheck extension if it is available at translatewiki.net | |
Issues | Open tasks · Report a bug |
LandingCheck makes using localized and geotargeted landing pages easy. It was created as a replacement for the GeoLite extension.
When called with a landing page name and a set of user-specific parameters, the extension checks to see if a version of the landing page exists for the user's language and country. If not, it looks for a version localized for the user's language. If that doesn't exist either, it looks for the English version. If any of those exist, it then redirects the user.
Installation
- <translate> [[<tvar name=2>Special:ExtensionDistributor/LandingCheck</tvar>|Download]] and move the extracted <tvar name=name>
LandingCheck
</tvar> folder to your <tvar name=ext>extensions/
</tvar> directory.</translate>
<translate> Developers and code contributors should install the extension [[<tvar name=git>Special:MyLanguage/Download from Git</tvar>|from Git]] instead, using:</translate>cd extensions/
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/LandingCheck - <translate> Add the following code at the bottom of your <tvar name=1>LocalSettings.php </tvar> file:</translate>
wfLoadExtension( 'LandingCheck' );
- File:OOjs UI icon check-constructive.svg <translate> Done</translate> – <translate> Navigate to <tvar name=special>Special:Version</tvar> on your wiki to verify that the extension is successfully installed.</translate>
Configuration
Parameter | Default | Comment |
---|---|---|
$wgPriorityCountries | array() | If there are any countries for which the country page should be the fallback rather than a language page, add its country code to this array. |
$wgLandingCheckPriorityURLBase | null | It is possible to configure a separate server running LandingCheck to handle requests for priority countries and another for non-priority countries. By default, the local instance of LandingCheck will handle both unless these variables are configured. The URLs contained in these variables should be the full URL to the location of LandingCheck - the query string will be appended. For example:
|
$wgLandingCheckNormalURLBase | null | It is possible to configure a separate server running LandingCheck to handle requests for priority countries and another for non-priority countries. By default, the local instance of LandingCheck will handle both unless these variables are configured. The URLs contained in these variables should be the full URL to the location of LandingCheck - the query string will be appended. For example:
|
How it works
GeoIP lookup: Normally LandingCheck does not perform a GeoIP lookup, but depends on the referring page to supply the user's country. If the country parameter is not supplied, the extension checks to see if the geoip_country_code_by_name() function exists (from the php5-geoip package), and if so, performs its own GeoIP lookup. (As of 2010, all Wikimedia page views perform a GeoIP lookup and record the user's country in the global JavaScript variable Geo.country
.)
Language: LandingCheck looks for whatever landing pages correspond to the user's wgUserLanguage
variable. If none exist, it tries to find landing pages in the corresponding fallback language. So, for example, if JimmyAppeal/pt-br doesn't exist, it looks for JimmyAppeal/pt, and then JimmyAppeal/en (English is the final fallback for all languages).
Usage
Set up landing pages
First, create a set of localized landing pages using the following naming scheme: <pagename>/<language>/<country>. For a fundraising campaign, you might set up the following pages:
- JimmyAppeal/en - landing page localized to English
- JimmyAppeal/en/US - landing page localized to English and customized for users in the United States
- JimmyAppeal/en/GB - landing page localized to English and customized for users in the United Kingdom
- JimmyAppeal/en/FR - landing page localized to English and customized for users in France
- JimmyAppeal/fr - landing page localized to French
- JimmyAppeal/fr/FR - landing page localized to French and customized for users in France
- JimmyAppeal/fr/CA - landing page localized to French and customized for users in Canada
Create link
Next, set up a link that uses JavaScript to construct the LandingCheck URL with user-specific query string parameters.
jQuery example
<script type="text/javascript">
var cn_rewrite_url = function() {
var baseUrl = 'http://wikimediafoundation.org/wiki/Special:LandingCheck';
var queryString = jQuery.param({'landing_page':'JimmyAppeal', 'language':wgUserLanguage, 'country':Geo.country});
jQuery("a.variable_lp").attr("href", baseUrl + '?' + queryString);
}
jQuery(document).ready(cn_rewrite_url);
</script>
<a class="variable_lp" href="">Read an Appeal by Jimmy Wales</a>
jQuery example with tracking
<script type="text/javascript">
var cn_rewrite_url = function() {
var baseUrl = 'http://wikimediafoundation.org/wiki/Special:LandingCheck';
var queryString = jQuery.param({'landing_page':'JimmyAppeal', 'language':wgUserLanguage, 'country':Geo.country, 'utm_source':'banner22', 'utm_medium':'sitenotice', 'utm_campaign':'2010fundraiser'});
jQuery("a.variable_lp").attr("href", baseUrl + '?' + queryString);
}
jQuery(document).ready(cn_rewrite_url);
</script>
<a class="variable_lp" href="">Read an Appeal by Jimmy Wales</a>
non-jQuery example
<a href="#" onclick="window.location.href='http://wikimediafoundation.org/wiki/Special:LandingCheck?landing_page=JimmyAppeal&language='+wgUserLanguage+'&country='+Geo.country">Read an Appeal by Jimmy Wales</a>
Add more landing pages
As additional localized and geotargeted landing pages are created, users will automatically start being directed to them. Make sure that any new landing pages added after your link has gone live are ready to use immediately. If you need to build new localized or geotargeted landing pages gradually, build them under different names and then move them into place once they are complete.
Overrides for level-1 chapters
During the 2010 fundraiser the Wikimedia Foundation was required to send all traffic from chapter countries to chapter-specific landing pages even if they did not support the user's language. To facilitate this, an override mechanism was built into LandingCheck. Level 1 chapters were instructed to build their landing pages using the following naming scheme: <pagename>/<country>/language>. For example:
- JimmyAppeal/GB - default landing page for United Kingdom (in English)
- JimmyAppeal/GB/fr - landing page for United Kingdom localized to French
- JimmyAppeal/GB/de - landing page for United Kingdom localized to German
The country codes of the level 1 chapters were then added to the $wgPriorityCountries global variable.
File:Wikimedia-logo black.svg | <translate> This {{<tvar name=1>#ifeq:Extension|Extension</tvar>|extension|skin}} is being used on one or more [[<tvar name=2>m:Special:MyLanguage/Wikimedia projects</tvar>|Wikimedia projects]].</translate> <translate> This probably means that the {{<tvar name=1>#ifeq:Extension|Extension</tvar>|extension|skin}} is stable and works well enough to be used by such high-traffic websites.</translate> <translate> Look for this {{<tvar name=1>#ifeq:Extension|Extension</tvar>|extension's|skin's}} name in Wikimedia's <tvar name=2>CommonSettings.php</tvar> and <tvar name=3>InitialiseSettings.php</tvar> configuration files to see where it's installed.</translate> <translate> A full list of the {{<tvar name=1>#ifeq:Extension|Extension</tvar>|extensions|skins}} installed on a particular wiki can be seen on the wiki's <tvar name=ver>Special:Version</tvar> page.</translate> |