Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matomo integration in WikiJS is outdated #2525

Closed
ghost opened this issue Oct 1, 2020 · 0 comments · Fixed by #2526
Closed

Matomo integration in WikiJS is outdated #2525

ghost opened this issue Oct 1, 2020 · 0 comments · Fixed by #2526
Assignees

Comments

@ghost
Copy link

ghost commented Oct 1, 2020

Describe the bug
In the curent version of WikiJS (2.5.144), the Matomo integration constructs the tracking script Java Snippet using the variables siteId, serverHost and scriptUrl, which are supplied by the user (see definition.yml and code.yml).

I had a look at the source code in Matomo just now and saw that the scriptUrl variable is unnecessary because the tracking script URL can be constructed using just the serverHost variable.

Additionally, the option g.defer=true; was removed and the var_paq variable was changed in Matomo in July this year.

WikiJS integration

  <!-- 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="{{serverHost}}/";
      _paq.push(['setTrackerUrl', u+'matomo.php']);
      _paq.push(['setSiteId', '{{siteId}}']);
      var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
      g.type='text/javascript'; g.async=true; g.defer=true; g.src='{{scriptUrl}}'; s.parentNode.insertBefore(g,s);
    })();
  </script>
  <noscript><p><img src="{{serverHost}}/matomo.php?idsite={{siteId}}&amp;rec=1" style="border:0;" alt="" /></p></noscript>
  <!-- End Matomo Code -->

Matomo (emphasis mine)

  <!-- Matomo -->
  <script type="text/javascript">
# var _paq = window._paq = window._paq || [];
  /* tracker methods like "setCustomDimension" should be called before "trackPageView" */
  _paq.push(['trackPageView']);
  _paq.push(['enableLinkTracking']);
  (function() {
    var u="https://localhost/piwik/";
    _paq.push(['setTrackerUrl', u+'matomo.php']);
    _paq.push(['setSiteId', '1']);
    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
#   g.type='text/javascript'; g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
  })();
  </script>
  <!-- End Matomo Code -->

Screenshots

screenshot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant