3liz / lizmap-web-client

Transfer a QGIS project on a server, Lizmap is providing the web interface to browse it
https://www.lizmap.com
Mozilla Public License 2.0
249 stars 141 forks source link

Add new Open Source analytics options like Matomo, Open Web Analytics or Plausible #2836

Open arno974 opened 2 years ago

arno974 commented 2 years ago

Currently in the admin section only Google Analytics can be used to track the use of the application. It could be great to add as well some Open Source alternatives like Matomo (https://matomo.org/) or Open Web Analytics (https://www.openwebanalytics.com/).

carekapt commented 2 years ago

I arrived at this page because of Matomo and Lizmap...trying to understand if I could somewhere put the code for an invisible image tracking (where a few android browsers like Brave don't allow this kind of tracking) like this:

<!-- Matomo Image Tracker-->
<img referrerpolicy="no-referrer-when-downgrade" src="https://mymatomo.example.com/matomo.php?idsite=100&amp;rec=1" style="border:0" alt="" />
<!-- End Matomo -->

For the users that don't care about the image tracking option on Matomo, I'm currently using a .js file on /media/project folder to keep track of users accessing that specific project... If anyone wants the 'recipe', reply to my comment

Kind regards, NMS

Gustry commented 2 years ago

Hi, thanks for the contribution,

It's up to you, but the best to share the recipe, you can make a pull request on github https://github.com/3liz/lizmap-javascript-scripts/ ;-)

carekapt commented 2 years ago

Hi, thanks for the contribution,

It's up to you, but the best to share the recipe, you can make a pull request on github https://github.com/3liz/lizmap-javascript-scripts/ ;-)

Take my matomo_tracker.js code:

 var _paq = window._paq || [];
  var website_domain="*.myWebSiteDomain"; /* change this for your domain */
  var u="https:/matomo_end_point_url/";   /* change this for your matomo endpoint url*/
  var websiteID = 1;                      /* change this for your site id on Matomo */

  _paq.push(["setDocumentTitle", document.domain + "/" + document.title]);
  _paq.push(["setCookieDomain", website_domain]);
  _paq.push(['enableLinkTracking']);
  _paq.push(['trackPageView']);
  _paq.push(['enableLinkTracking']);

  (function() {

      _paq.push(['addTracker', u+'matomo.php', websiteID]);
      _paq.push(['setTrackerUrl', u+'matomo.php']);
    _paq.push(['setSiteId', 'websiteID']);
    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
    g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);

  })();
nboisteault commented 3 weeks ago

Here is an example on how to use plausible with Lizmap : https://demo.lizmap.com/lizmap/index.php/view/media/getMedia?repository=features&project=covid_19_fr&mtime=1718197872&path=media%2Fjs%2Fcovid_19_fr%2F_download.js