History: Matomo
Source of version: 56 (current)
Copy to clipboard
! Matomo Web analytics {QUOTE(source_url="https://matomo.org/faq/new-to-piwik/#faq_13")} [http://matomo.org/|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.{QUOTE} 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: {CODE(caption="In Tiki5 or newer" colors="htmlmixed")} {literal} <!-- Matomo--> <script type="text/javascript"> ... ... ... </script> <!-- End Matomo Tag --> {/literal} {CODE} 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 {CODE(caption="Only use the tracking code for users that do not have full admin rights")} {if $tiki_p_admin neq 'y'} {literal} <!-- Matomo --> <script type="text/javascript"> ... ... ... </script> <!-- End Matomo Tag --> {/literal} {/if} {CODE} !!! 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. {CODE(caption="Pass Tiki username to Matomo, see analytics of user activity in Matomo reports")} {literal} <!-- Matomo --> <sc ript type="text/javascript"> ... ... ... {/literal} {if $user}{literal} _paq.push(['setUserId', {/literal}'{$user}'{literal}]);{/literal} {/if}{literal} _paq.push(['trackPageView']); ... ... ... </script> <!-- End Matomo Tag --> {/literal} {CODE} !!!!Matomo Visitor Log with Tiki user information {img type="fileId" fileId="1504" thumb="box" width="400px" desc="Matomo Visitor Log shows activity of Tiki user 'admin' in the first two sessions and an anonymous user in the session after that" alt="Matomo Visitor Log with Tiki user info"} !! Embedding Matomo report on a wiki page It is possible to embed Matomo report into wiki page. *In Matomo Admin **Permission and User ##Go to setting, users. ## 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===). ##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 ##Click on the user icon (top right), select widget ##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. ##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 ##Create or edit the page where you want to display the report. ##Set permission for your usage (it can be embedded inside group plugin for example). ##Insert an HTML plugin and paste the code you've prepared. ##Approve the plugin ##Tada ! --- !!!Visits Summary, Visits Overview (with graph) for doc.tiki.org (previous day) {HTML()}<div id="widgetIframe"><iframe width="100%" height="350" src="https://piwik.tiki.org/index.php?module=Widgetize&action=iframe&widget=1&moduleToWidgetize=VisitsSummary&actionToWidgetize=index&idSite=1&period=day&date=yesterday&disableLink=1&widget=1&token_auth=68c470801c52ab65597ad347c27dca25" scrolling="no" frameborder="0" marginheight="0" marginwidth="0"></iframe></div>{HTML} --- !!!Visitor Setting, Screen Resolution for doc.tiki.org (previous day) {HTML()}<div id="widgetIframe"><iframe width="100%" height="350" src="https://piwik.tiki.org/index.php?module=Widgetize&action=iframe&widget=1&moduleToWidgetize=Resolution&actionToWidgetize=getResolution&idSite=1&period=day&date=yesterday&disableLink=1&widget=1&token_auth=68c470801c52ab65597ad347c27dca25" scrolling="no" frameborder="0" marginheight="0" marginwidth="0"></iframe></div>{HTML} --- !!!Actions, Pages for doc.tiki.org (previous day) {HTML()}<div id="widgetIframe"><iframe width="100%" height="350" src="https://piwik.tiki.org/index.php?module=Widgetize&action=iframe&widget=1&moduleToWidgetize=Actions&actionToWidgetize=getPageUrls&idSite=1&period=day&date=yesterday&disableLink=1&widget=1&token_auth=68c470801c52ab65597ad347c27dca25" scrolling="yes" frameborder="0" marginheight="0" marginwidth="0"></iframe></div>{HTML} ~tc~Should be copied to dev and deleted or simply deleted --- !!!Creating a Plugin for Tiki ! Requirement #Install on all page "JavaScript Tracking Code" +{CODE()}<!-- Matomo--> <script type="text/javascript"> var _paq = _paq || []; _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); (function() { var u="//domain_name/piwikwebsite_name/"; _paq.push(['setTrackerUrl', u+'piwik.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.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s); })(); </script> <noscript><p><img src="//localhost:8888/piwik/piwik.php?idsite=1" style="border:0;" alt="" /></p></noscript> <!-- End Piwik Code -->{CODE} +''Installed at tiki-admin.php?page=look in the meantime'' !!!!Notes: *Parameters and customized report can be achieved using API command: http://developer.piwik.org/api-reference/reporting-api *The widget will display the content using country language based on IP or browser AND NOT based on Tiki language . (more to come...) !!!!To-Do: *--http vs https-- *Adding date range *Adding periods *Force height for specific widget *Set filtering and sort (&filter_sort_column=gt_ms) *Hide columns properly (&hideColumns=avg_time_on_page) set data to "-" but display the column. *Have the widget language set to Tiki language preferences. *Get 404 pages (http://piwik.org/faq/how-to/faq_60/) *Find is slow pages or slow query can be added to report *Verbose error (token hs or no server url error) (more to come...) Documentation available at : http://piwik.org/docs/embed-piwik-report/~/tc~ See also ((themes:Template Tricks)) Related: ((Google Analytics)) ~tc~ (alias(Piwik)) ~/tc~