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

Merge upstream changes into Matomo integration #2526

Merged
merged 1 commit into from Oct 3, 2020
Merged

Merge upstream changes into Matomo integration #2526

merged 1 commit into from Oct 3, 2020

Conversation

ghost
Copy link

@ghost ghost commented Oct 1, 2020

This pull request fixes #2525 by merging the upstream changes to Matomo's tracking script into the integration in WikiJS.

Example tracking script generated by WikiJS with this PR

<!-- 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://matomo.datahoarder.dev/";
    _paq.push(['setTrackerUrl', u+'matomo.php']);
    _paq.push(['setSiteId', '2']);
    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>
<noscript><p><img src="https://matomo.datahoarder.dev/matomo.php?idsite=2&amp;rec=1" style="border:0;" alt="" /></p></noscript>
<!-- End Matomo Code -->

Example tracking script generated by Matomo

<!-- 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://matomo.datahoarder.dev/";
    _paq.push(['setTrackerUrl', u+'matomo.php']);
    _paq.push(['setSiteId', '2']);
    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 -->

Visits via Tor Browser (no Javascript) and via VPN (with JavaScript) are being successfully logged in Matomo with this PR.

Signed-off-by: Aaron <admin@datahoarder.dev>
@kennyparsons
Copy link

I successfully tested the matomo code.yml and definition.yml and it worked. Using Wiki.Js in a docker envrironment:

version: "3"
services:

  wiki_db:
    image: postgres:11-alpine
    container_name: wiki.js_db
    environment:
      POSTGRES_DB: wiki
      POSTGRES_PASSWORD: ****
      POSTGRES_USER: wikijs
    logging:
      driver: "none"
    restart: always
    volumes:
      - /opt/docker/wikijs/db:/var/lib/postgresql/data

  wiki:
    image: requarks/wiki:latest
    container_name: wiki.js
    depends_on:
      - wiki_db
    environment:
      DB_TYPE: postgres
      DB_HOST: wiki_db
      DB_PORT: 5432
      DB_USER: wikijs
      DB_PASS: ***
      DB_NAME: wiki
    restart: always
    volumes:
      - /opt/docker/wikijs/wiki/matomo-code.yml:/wiki/server/modules/analytics/matomo/code.yml
      - /opt/docker/wikijs/wiki/matomo-definition.yml:/wiki/server/modules/analytics/matomo/definition.yml
    ports:
      - "3000:3000"

This does make the analytics module work, but the 3rd field in the definition still remains. Some magic needs to happen in the DB to get rid of it.

@ghost
Copy link
Author

ghost commented Oct 1, 2020

This does make the analytics module work, but the 3rd field in the definition still remains. Some magic needs to happen in the DB to get rid of it.

To be specific, one has to remove the scriptUrl variable from the key matomo in the analytics table.

@ghost
Copy link
Author

ghost commented Oct 3, 2020

@NGPixel Is it feasible to include an automatic migration for that database table with the next update?

@NGPixel NGPixel merged commit 23e3403 into requarks:dev Oct 3, 2020
@NGPixel
Copy link
Member

NGPixel commented Oct 3, 2020

No migration necessary, the initialization script will be modified to remove unused parameters.

@ghost ghost deleted the matomo-patch branch October 3, 2020 22:13
jionggyu pushed a commit to jionggyu/wiki-2.5.302-patch that referenced this pull request Jul 9, 2024
Signed-off-by: Aaron <admin@datahoarder.dev>
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 this pull request may close these issues.

Matomo integration in WikiJS is outdated
2 participants