Loading...
 
Skip to main content

Matomo Web analytics

Matomo, formerly known as Piwik, is a downloadable, Free (GPL licensed) web analytics software platform. It provides detailed reports on your website and its visitors, including the search engines and keywords they used, the language they speak, which pages they like, the files they download and so much more. Matomo (Piwik) aims to be an open source alternative to Google Analytics.


Like Tiki, Matomo is written in PHP and uses a MySQL database.

Integrating Matomo with Tiki

To record visitors, visits and page views in Matomo, you must add a Tracking code in all your pages. Matomo recommend to use the standard JavaScript Tracking tag.

The documentation is here:
http://matomo.org/docs/javascript-tracking/

Copy the code from Matomo and paste in Admin -> Look & Feel -> General Layout or Customization (depends on your version of Tiki) -> Custom End of <body> Code surrounded by literal tags, as shown below:

In Tiki5 or newer
Copy to clipboard
{literal} <!-- Matomo--> <script type="text/javascript"> ... ... ... </script> <!-- End Matomo Tag --> {/literal}


The literal tags indicate to the Smarty template engine not to interpret the code and to pass it as-is.

direct URL to access Custom End of <body> Code is: tiki-admin.php?page=look&cookietab=2

Only use the tracking code for users that do not have full admin rights
Copy to clipboard
{if $tiki_p_admin neq 'y'} {literal} <!-- Matomo --> <script type="text/javascript"> ... ... ... </script> <!-- End Matomo Tag --> {/literal} {/if}

Going Further

To identify users logged into Tiki and track their activity, modify the default Matomo code to pass the Tiki username to Matomo . This is done by adding the following in Admin -> Look & Feel -> Custom End of <body> Code. Note that the Tiki username must be passed before 'trackPageView' in the default Matomo code to track user activity reliably.

Pass Tiki username to Matomo, see analytics of user activity in Matomo reports
Copy to clipboard
{literal} <!-- Matomo --> <script type="text/javascript"> ... ... ... {/literal} {if $user}{literal} _paq.push(['setUserId', {/literal}'{$user}'{literal}]);{/literal} {/if}{literal} _paq.push(['trackPageView']); ... ... ... </script> <!-- End Matomo Tag --> {/literal}

Matomo Visitor Log with Tiki user information

Matomo Visitor Log with Tiki user info
Matomo Visitor Log shows activity of Tiki user 'admin' in the first two sessions and an anonymous user in the session after that

Embedding Matomo report on a wiki page

It is possible to embed Matomo report into wiki page.

  • In Matomo Admin
    • Permission and User
    1. Go to setting, users.
    2. Set permission for anonymous so all the data will be public or create a specific user to create a token that will be used for authentication (recommended and explained here).
    3. In Manage Access give this user "View" permission for the website(s) you want the token to be used to share the report.
    • Report Selection and Credentials
    1. Click on the user icon (top right), select widget
    2. Select the kind of report you want to display and copy the HTML code found in the field "Embed Iframe" (at the bottom of the preview). Paste it in a text-editor.
    3. Add at the end of the "src" (it should start by "http://example.org...") the parameter to the API calls URLs that require authentication: "&token_auth=". Paste the token_auth you created for your specific user.


You have now all the necessary and basic code that should be placed in a Tiki Wiki page.

  • In Tiki
    1. Create or edit the page where you want to display the report.
    2. Set permission for your usage (it can be embedded inside group plugin for example).
    3. Insert an HTML plugin and paste the code you've prepared.
    4. Approve the plugin
    5. Tada !

Visits Summary, Visits Overview (with graph) for doc.tiki.org (previous day)


Visitor Setting, Screen Resolution for doc.tiki.org (previous day)


Actions, Pages for doc.tiki.org (previous day)



See also Template Tricks

Related: Google Analytics