Basic Matomo Analytics support
authorDan Scott <dan@coffeecode.net>
Wed, 3 Jul 2019 18:19:42 +0000 (14:19 -0400)
committerDan Scott <dan@coffeecode.net>
Wed, 3 Jul 2019 19:14:37 +0000 (15:14 -0400)
After you have set up a Matomo Analytics server, you can track web analytics by
customizing templates/opac/parts/config.tt2 to identify your Matomo server URL
and the ID of the site you are tracking.

Signed-off-by: Dan Scott <dan@coffeecode.net>
Open-ILS/src/templates/opac/parts/base.tt2
Open-ILS/src/templates/opac/parts/config.tt2
Open-ILS/src/templates/opac/parts/matomo_analytics.tt2 [new file with mode: 0644]
docs/admin_initial_setup/designing_your_catalog.adoc
docs/opac/new_skin_customizations.adoc

index aa12e39..c18a981 100644 (file)
@@ -39,6 +39,7 @@
 
         [% IF !ctx.is_staff %]
             [% INCLUDE 'opac/parts/goog_analytics.tt2' %]
+            [% INCLUDE 'opac/parts/matomo_analytics.tt2' %]
         [% END %]
         [% PROCESS 'opac/parts/stripe.tt2' %]
     </head>
index b0ad747..b160847 100644 (file)
@@ -51,6 +51,17 @@ google_analytics.enabled = 'false';
 google_analytics.code = 'UA-9999999-99';
 
 ##############################################################################
+# Matomo Analytics support
+##############################################################################
+# You can enable Matomo Analytics support in Evergreen by specifying your
+# Matomo Analytics URL, the ID of the site you are tracking, and changing
+# 'false' to 'true'
+##############################################################################
+matomo_analytics.enabled = 'false';
+matomo_analytics.url = 'https://example.com/matomo';
+matomo_analytics.site = '1';
+
+##############################################################################
 # Ebook API integration
 ##############################################################################
 ebook_api.enabled = 'false';
diff --git a/Open-ILS/src/templates/opac/parts/matomo_analytics.tt2 b/Open-ILS/src/templates/opac/parts/matomo_analytics.tt2
new file mode 100644 (file)
index 0000000..5f2ffd8
--- /dev/null
@@ -0,0 +1,18 @@
+[%- PROCESS "opac/parts/header.tt2";
+    IF matomo_analytics.enabled == 'true' -%]
+<!-- 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="[% matomo_analytics.url %]";
+    _paq.push(['setTrackerUrl', u+'matomo.php']);
+    _paq.push(['setSiteId', '[% matomo_analytics.site %]']);
+    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 -->
+[%- END -%]
index 5660821..99a4582 100644 (file)
@@ -563,6 +563,27 @@ will need to edit _config.tt2_ in your template. To enable the service set
 the value of google_analytics.enabled to true and change the value of 
 _google_analytics.code_ to be the code in your Google Analytics account.
 
+Matomo Analytics
+~~~~~~~~~~~~~~~~
+
+Matomo Analytics (https://matomo.org/) is free software that you can host
+yourself, so that you can collect web site statistics without sharing your
+users' data with third parties.  Statistic tracking is disabled by default
+through the Evergreen client software when library staff use your site within
+the client, but active when anyone uses the site without the client.  This was
+a preventive measure to reduce the potential risks for leaking patron
+information. To use Matomo Analytics you need to:
+
+. Set up a hosted instance of Matomo
+. Add your Evergreen catalogue as a site
+. Edit _config.tt2_ in your templates as follows:
+.. Set the value of _matomo_analytics.enabled_ to _'true'_
+.. Set the value of _matomo_analytics.url_ to the location of your Matomo
+   Analytics site (for example, "https://opac.example.org/matomo")
+.. Set the value of _matomo_analytics.site_ to the site ID for your Evergreen
+  catalogue
+
+
 NoveList
 ~~~~~~~~
 
index 88ffee8..7576959 100644 (file)
@@ -50,7 +50,7 @@ NOTE: All paths are relative to `/openils/var/templates/opac`
   ** hiding the *Place Hold* button for available items
   ** enabling RefWorks support for citation management
   ** adding OpenURL resolution for electronic resources
-  ** enabling Google Analytics tracking for your TPAC
+  ** enabling Google Analytics or Matomo Analytics tracking for your TPAC
   ** displaying the "Forgot your password?" prompt
   ** controlling the size of cover art on the record details page
   ** defining which facets to display, and in which order