DaSchTour / matomo-mediawiki-extension

https://www.mediawiki.org/wiki/Extension:Piwik_Integration
17 stars 21 forks source link

Track 404 errors #46

Open samwilson opened 8 months ago

samwilson commented 8 months ago

The Matomo docs suggest tracking 404 errors like this:

Setup a custom 404 page: you can easily do this if you use a CMS (for example, in wordpress, all 404 pages are loading a custom 404 template). If you don’t use a Content Management System, you can usually specify a 404 custom page in your webserver configuration file. Add the Matomo tracking code in this custom 404 page. In the Javascript tracking code, add the following: _paq.push(['setDocumentTitle', '404/URL = ' + encodeURIComponent(document.location.pathname+document.location.search) + '/From = ' + encodeURIComponent(document.referrer)]);

Is this something that this extension could handle?

samwilson commented 8 months ago

There's some more information here, and an alternative way to track 404s: https://github.com/matomo-org/matomo/issues/6580

Seb35 commented 6 months ago

Indeed, it would be something useful to understand what the visitors do not find – MediaWiki has already the special pages Wanted* (WantedPages, WantedCategories, …) but it’s more from the point of view of the editors (what pages should we create?) instead of the visitors (what pages do we want to see? including pages not anticipated by the editors).

Given Matomo has no official method to support that (but it could appear in the future), perhaps the best way for now is to use one of the method described in the links in the parameter $wgMatomoCustomJS (which is written before the call to trackPageView):

And experiment what is the more convenient. When a method will be stable, it could be documented on the mediawiki.org page.

Seb35 commented 6 months ago

And experiment what is the more convenient. When a method will be stable, it could be documented on the mediawiki.org page.

Ah, I realise some support from this extension is necessary to conditionnally include this JS snippet only on the 404 page, or perhaps more generally add a JS variable with the HTTP status code to be retrieved with mw.config.get( 'wgHTTPStatus' );

EDIT: and I see your PR #47.

samwilson commented 6 months ago

Yeah it's odd that Matomo doesn't have a better way to track them, but changing the title seems to work okay. The adding of the slashes means that it displays it grouped in the same way it does other directories.

Does that PR look ok?

samwilson commented 3 months ago

@Seb35 Gentle reminder about this. Let me know if you want me to update the PR in any way.