{"id":15704106,"url":"https://github.com/octfx/mediawiki-extension-plausible","last_synced_at":"2025-09-04T18:13:16.775Z","repository":{"id":39661627,"uuid":"345940754","full_name":"octfx/mediawiki-extension-Plausible","owner":"octfx","description":"GDPR compliant Website Analytics","archived":false,"fork":false,"pushed_at":"2024-08-12T12:11:28.000Z","size":189,"stargazers_count":7,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-20T13:36:56.334Z","etag":null,"topics":["mediawiki-extension","plausible-analytics"],"latest_commit_sha":null,"homepage":"https://www.mediawiki.org/wiki/Extension:Plausible","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/octfx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-09T08:49:36.000Z","updated_at":"2024-08-12T12:11:31.000Z","dependencies_parsed_at":"2023-10-04T02:34:30.199Z","dependency_job_id":"292ea045-b645-441e-99ef-e1c663f21087","html_url":"https://github.com/octfx/mediawiki-extension-Plausible","commit_stats":{"total_commits":51,"total_committers":3,"mean_commits":17.0,"dds":"0.27450980392156865","last_synced_commit":"e9d75c3d0ff65a1014d3f7bf23e2d0ebb336d666"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/octfx%2Fmediawiki-extension-Plausible","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/octfx%2Fmediawiki-extension-Plausible/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/octfx%2Fmediawiki-extension-Plausible/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/octfx%2Fmediawiki-extension-Plausible/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/octfx","download_url":"https://codeload.github.com/octfx/mediawiki-extension-Plausible/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253761013,"owners_count":21960052,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mediawiki-extension","plausible-analytics"],"created_at":"2024-10-03T20:10:21.850Z","updated_at":"2025-05-12T14:58:41.659Z","avatar_url":"https://github.com/octfx.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Plausible Analytics\n\nPlausible Analytics is a simple, lightweight (\u003c 1 KB), open-source and privacy-friendly alternative to Google Analytics. It doesn’t use cookies and is fully compliant with GDPR, CCPA and PECR.\n\nSee https://github.com/plausible/analytics\n\n## Installation\n* Download, extract and place the file(s) in a directory called Plausible in your extensions/ folder.\n* Add the following code at the bottom of your LocalSettings.php file:\n```php\nwfLoadExtension( 'Plausible' );  \n$wgPlausibleDomain = \"https://plausible.io\";  \n$wgPlausibleDomainKey = \"mywiki.example.com\"; // change to your site address\n$wgPlausibleApikey = ''; // Only necessary when using Extension:PageViewInfo\n```\n* Configure as required.\n* Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.\n\n## Configuration\n| Key                                     | Description                                                                                                                                                                        | Example                    | Default |\n|-----------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------|---------|\n| $wgPlausibleDomain                      | Plausible Domain. **Required**                                                                                                                                                     | https://plausible.io       | null    |\n| $wgPlausibleDomainKey                   | Domain Key set on the plausible website. **Required**                                                                                                                              | plausible.io               | null    |\n| $wgPlausibleApiKey                      | Auth Bearer key for integration with [Extension:PageViewInfo](https://www.mediawiki.org/wiki/Extension:PageViewInfo)                                                               |                            |         |\n| $wgPlausibleHonorDNT                    | Honor the Do Not Track header and disable tracking.                                                                                                                                | false                      | true    |\n| $wgPlausibleTrackOutboundLinks          | Enable Tracking of outbound link clicks.                                                                                                                                           | true                       | false   |\n| $wgPlausibleTrackFileDownloads          | Enable Tracking of link clicks that lead to files, sending a `File Download` event. See [the official docs](https://plausible.io/docs/file-downloads-tracking).                    | true                       | false   |\n| $wgPlausibleTrackFileDownloadExtensions | List of additional file extensions to track. See [the official docs](https://plausible.io/docs/file-downloads-tracking#which-file-types-are-tracked).                              | ['js', 'py']               | []      |\n| $wgPlausibleTrackLoggedIn               | Enable Tracking for logged in users.                                                                                                                                               | true                       | false   |\n| $wgPlausibleEnableTaggedEvents          | Enable click tracking via css classes. See [the official docs](https://plausible.io/docs/custom-event-goals#2-add-a-css-class-name-to-the-element-you-want-to-track-on-your-site). | true                       | false   |\n| $wgPlausibleIgnoredTitles               | List of page titles that should not be tracked. [Examples](https://github.com/plausible/docs/blob/master/docs/excluding-pages.md#common-use-cases-and-examples).                   | ['/Page1', '/Special:*', ] | []      |\n| $wgPlausibleEnableOptOutTag             | Enables or disables the `\u003cplausible-opt-out /\u003e` tag that allows users to opt-out from being tracked.                                                                               | false                      | true    |\n\n\n### Included tracking scripts\nThe following tracking modules can be activated by setting the provided configuration key in `LocalSettings.php` to true.\n\n| Key                                 | Description                                                                                                                                                                                               | Event Name                   |\n|-------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------|\n| $wgPlausibleTrack404                | Sends a `404` event for unknown titles.                                                                                                                                                                   | `404`                        |\n| $wgPlausibleTrackSearchInput        | Send inputs to `#searchInput` to plausible as a custom event named `Search: Input`.                                                                                                                       | `Search: Input`              |\n| $wgPlausibleTrackEditButtonClicks   | Track clicks to `#ca-edit a` as a custom event named `Edit Button: Click`.                                                                                                                                | `Edit Button: Click`         |\n| $wgPlausibleTrackNavplateClicks     | Track clicks to links inside `.navplate` elements.                                                                                                                                                        | `Navplate: Click`            |\n| $wgPlausibleTrackInfoboxClicks      | Track clicks to links inside `.mw-capiunto-infobox` and `.infobox` elements.                                                                                                                              | `Infobox: Click`             |\n| $wgPlausibleTrackCitizenSearchLinks | Only for [Skin:Citizen](https://github.com/StarCitizenTools/mediawiki-skins-Citizen). Track clicks to search result links found in `#typeahead-suggestions`. Event is named `Citizen: Search Link Click`. | `Citizen: Search Link Click` |\n| $wgPlausibleTrackCitizenMenuLinks   | Only for [Skin:Citizen](https://github.com/StarCitizenTools/mediawiki-skins-Citizen). Track clicks to links in the sidebar menu. Event is named `Citizen: Menu Link Click`.                               | `Citizen: Menu Link Click`   |\n\n### Server Side Tracking\nSome events can be sent serverside without having to rely on the included plausible client script.\n\nThe following custom events can be activated: \n```php\n# Default Configuration\n$wgPlausibleServerSideTracking = [\n    // Event Name: pageview\n    'pageview' =\u003e false,\n    // Event Name: 404 \n    'page404' =\u003e false,\n    // Event Name: Page: Edit \n    'pageedit' =\u003e true, // Page has been successfully edited\n    // Event Name: Page: Delete\n    'pagedelete' =\u003e true, // Page has been deleted\n    // Event Name: Page: Undelete\n    'pageundelete' =\u003e true, // Page has been undeleted\n    // Event Name: Page: Move\n    'pagemove' =\u003e true, // Page was moved\n    // Event Name: User: Register\n    'userregister' =\u003e false, // A new user registered\n    // Event Name: User: Login\n    'userlogin' =\u003e false, // A user logged in\n    // Event Name: User: Logout\n    'userlogout' =\u003e  false, // A user logged out\n    // Event Name: File: Upload\n    'fileupload' =\u003e true, // A file was uploaded\n    // Event Name: File: Delete\n    'filedelete' =\u003e true, // A file was deleted\n    // Event Name: File: Undelete\n    'fileundelete' =\u003e true, // A file was undeleted\n    // Event Name: Search: Not found\n    'searchnotfound' =\u003e true, // A searched term was not found / has no title on the wiki\n    // Event Name: Search: Found\n    'searchfound' =\u003e true, // A searched term was found / has a corresponding title on the wiki\n];\n```\n\n### Event / Goal Names\nThis extension chooses the following convention for naming events / goals: `Subject: Event/Action`.\n\n## Tracking Custom Events\nhttps://github.com/plausible/docs/blob/master/docs/custom-event-goals.md\n\nIf you want to track custom event goals like button clicks or form completions, you have to trigger these custom events from your website using JavaScript.\n\nScripts need to be placed in `MediaWiki:\u003cYour Skin\u003e.js` e.g. `MediaWiki:Citizen.js`.\n\nExample: Tracking edit button clicks on [Skin:Citizen](https://github.com/StarCitizenTools/mediawiki-skins-Citizen).\n```js\nif (typeof window.plausible === 'undefined') {\n    return;\n}\n\ndocument.querySelector('#ca-edit a').addEventListener('click', function (event) {\n    plausible('Edit Button: Click');\n});\n```\n\n### Via css classes\nWith setting `$wgPlausibleEnableTaggedEvents = true;` click to elements can be tracked by setting css classes.\nFrom [the official docs](https://plausible.io/docs/custom-event-goals): \n\u003e You can also add class names directly in HTML\n\u003e If you can edit the raw HTML code of the element you want to track, you can also add the classes directly in HTML. For example:\n\u003e \n\u003e ```\u003c!-- before --\u003e```  \n\u003e ```\u003cbutton\u003eClick Me\u003c/button\u003e```  \n\u003e ```\u003c!-- after --\u003e```  \n\u003e ```\u003cbutton class=\"plausible-event-name=Button+Click\"\u003eClick Me\u003c/button\u003e```\n\u003e \n\u003e Or if your element already has a class attribute, just separate the new ones with a space:\n\u003e\n\u003e ```\u003c!-- before --\u003e```  \n\u003e ```\u003cbutton class=\"some-existing-class\"\u003eClick Me\u003c/button\u003e```\n\u003e \n\u003e ```\u003c!-- after --\u003e```  \n\u003e ```\u003cbutton class=\"some-existing-class plausible-event-name=Button+Click\"\u003eClick Me\u003c/button\u003e```\n\n\u003e When you send custom events to Plausible, they won't show up in your dashboard automatically. You'll have to configure the goal for the conversion numbers to show up.\n\n## Ignoring Pages\nhttps://github.com/plausible/docs/blob/master/docs/excluding-pages.md#common-use-cases-and-examples\n\nBy default, Plausible Analytics tracks every page you install the snippet on. If you don't want Plausible to track specific pages, do not include the snippet on those pages.\n\n## Common use cases and examples\n| $wgPlausibleIgnoredTitles input | Prevents tracking on pages with a URL path of:                                                                                                                                                                   |\n|---------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `/blog4`                        | `/blog4` and exactly `/blog4` with nothing before or after it, so not `/blog45` nor `/blog4/new` nor `/blog`                                                                                                     |\n| `/rule/*`                       | `/rule/\u003canything\u003e`, with `\u003canything\u003e` being any set of characters (length \u003e=0), but not a forward slash - for example, both `/rule/1` as well as `/rule/general-rule-14`, but not `/rule/4/details` nor `/rules` |\n| `/how-to-*`                     | `/how-to-\u003canything\u003e` - for example, `/how-to-play` or `/how-to-succeed`, but not `how-to-/blog`                                                                                                                  |\n| `/*/admin`                      | `/\u003canything\u003e/admin` - for example, `/sites/admin`, but not `/sites/admin/page-2` nor `/sites/2/admin` nor `/admin`                                                                                               |\n| `/*/priv/*`                     | `/\u003canything\u003e/priv/\u003canything\u003e` - for example, `/admin/priv/sites`, but not `/priv` nor `/priv/page` nor `/admin/priv`                                                                                             |\n| `/rule/*/*`                     | `/rule/\u003canything\u003e/\u003canything\u003e` - for example, `/rule/4/new/` or `/rule/10/edit`, but not `/rule` nor `/rule/10/new/save`                                                                                          |\n| `/wp/**`                        | `/wp\u003canything, even slashes\u003e` - for example, `/wp/assets/subdirectory/another/image.png` or `/wp/admin`, and everything in between, but not `/page/wp`                                                           |\n\n## Lua Integration\nWith [Extension:PageViewInfo](https://www.mediawiki.org/wiki/Extension:PageViewInfo) active, plausible exposes the following functions:\n\n1. `mw.ext.plausible.topPages()`\nReturns the top pages and the views for the last day. The table is ordered by the number of page views, and can be iterated by using `ipairs`.  \nExample:\n```lua\nlocal result = mw.ext.plausible.topPages()\n\u003e {\n  {\n    page = \"Foo\",\n    views = 100\n  },\n  {\n    page = \"Bar\",\n    views = 80\n  },\n  { [...] }\n}\n```\n\nAlternatively this function can be called with the number of days to calculate the views over, e.g. `mw.ext.plausible.topPages( 30 )`.  \nThis is _expensive_  as no caching is employed.\n\n2. `mw.ext.plausible.pageData( titles, days )`\nReturns the page views for the given titles over the last N days.  \nExample:\n```lua\nlocal result = mw.ext.plausible.pageData( { \"Foo\", \"Bar\" }, 5 )\n\u003e {\n  [\"Foo\"] = {\n    [\"2023-08-04\"] = 10,\n    [\"2023-08-05\"] = 1,\n    [\"2023-08-06\"] = 4,\n    [\"2023-08-07\"] = 7,\n    [\"2023-08-08\"] = 1,\n    [\"2023-08-09\"] = 4,\n  },\n  [\"Bar\"] = {\n    [\"2023-08-04\"] = 100,\n    [\"2023-08-05\"] = 14,\n    [\"2023-08-06\"] = 54,\n    [\"2023-08-07\"] = 7,\n    [\"2023-08-08\"] = 31,\n    [\"2023-08-09\"] = 1,\n  },\n}\n```\n\n3. `mw.ext.plausible.siteData( days )`\nReturns the site views for the given last N days.  \nExample:\n```lua\nlocal result = mw.ext.plausible.siteData( 5 )\n\u003e {\n  [\"2023-08-04\"] = 10,\n  [\"2023-08-05\"] = 1,\n  [\"2023-08-06\"] = 4,\n  [\"2023-08-07\"] = 7,\n  [\"2023-08-08\"] = 1,\n  [\"2023-08-09\"] = 4,\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foctfx%2Fmediawiki-extension-plausible","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foctfx%2Fmediawiki-extension-plausible","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foctfx%2Fmediawiki-extension-plausible/lists"}