Page MenuHomePhabricator

Setup Matomo beacon for techblog.wikimedia.org
Closed, ResolvedPublic

Description

We would like to have a privacy respecting page view tracking system for the new techblog.wikimedia.org blog. The piwik Matomo deployment that is used for various non-MediWiki Wikimedia sites seems like our best hope for this.

  • Get some nice person with admin access at https://piwik.wikimedia.org/ to add a "techblog" site
  • Add tracking javascript to techblog
  • Profit!!

Event Timeline

bd808 triaged this task as High priority.Mar 18 2020, 4:33 AM

We will try using https://wordpress.org/plugins/wp-piwik/ to manage the tracker script integration with the blog. To do this we will apparently need an token_auth for a user with 'view' permission from https://piwik.wikimedia.org/.

We will try using https://wordpress.org/plugins/wp-piwik/ to manage the tracker script integration with the blog. To do this we will apparently need an token_auth for a user with 'view' permission from https://piwik.wikimedia.org/.

That plugin turned out to be less than ideal. We are instead going to make a super light custom plugin. All that I will need for that is the SiteId for the new site.

Matomo code:

<!-- Matomo -->
<script type="text/javascript">
  var _paq = window._paq || [];
  /* tracker methods like "setCustomDimension" should be called before "trackPageView" */
  _paq.push(['trackPageView']);
  _paq.push(['enableLinkTracking']);
  (function() {
    var u="//piwik.wikimedia.org/";
    _paq.push(['setTrackerUrl', u+'matomo.php']);
    _paq.push(['setSiteId', '22']);
    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);
  })();
</script>
<!-- End Matomo Code -->