upgrade piwik code for matomo

Mon, 21 Oct 2019 18:20:59 +0200

author
David Douard <david.douard@sdfa3.org>
date
Mon, 21 Oct 2019 18:20:59 +0200
changeset 122
08b9a05b3d8d
parent 118
fb878b773377
child 123
6b5f7fb06a51

upgrade piwik code for matomo

pelicanconf.py file | annotate | diff | comparison | revisions
theme/templates/base.html file | annotate | diff | comparison | revisions
theme/templates/piwik.html file | annotate | diff | comparison | revisions
--- a/pelicanconf.py	Sat Oct 19 00:32:18 2019 +0200
+++ b/pelicanconf.py	Mon Oct 21 18:20:59 2019 +0200
@@ -16,22 +16,22 @@
 if isprod:
     SITEURL = 'https://whatever.sdfa3.org'
     PIWIK = '''
+<!-- Matomo -->
 <script type="text/javascript">
-  var _paq = _paq || [];
-  _paq.push(["setDomains", ["*.whatever.sdfa3.org"]]);
+  var _paq = window._paq || [];
+  /* tracker methods like "setCustomDimension" should be called before "trackPageView" */
   _paq.push(['trackPageView']);
   _paq.push(['enableLinkTracking']);
   (function() {
-    var u="//piwik.sdfa3.org/";
-    _paq.push(['setTrackerUrl', u+'piwik.php']);
-    _paq.push(['setSiteId', 2]);
+    var u="https://piwik.sdfa3.org/";
+    _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.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
+    g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
   })();
 </script>
-<noscript><p><img src="//piwik.sdfa3.org/piwik.php?idsite=2" style="border:0;" alt="" /></p></noscript>
-<!-- End Piwik Code -->
-'''
+<!-- End Matomo Code -->
+    '''
 else:
     SITEURL = ''
     PIWIK = ''
--- a/theme/templates/base.html	Sat Oct 19 00:32:18 2019 +0200
+++ b/theme/templates/base.html	Mon Oct 21 18:20:59 2019 +0200
@@ -134,6 +134,12 @@
         </div>
         {% include 'trademark.html' %}
     </div>
+  {% if PIWIK %}
+  <noscript>
+  <img src="https://piwik.sdfa3.org/matomo.php?idsite=2&amp;rec=1" style="border:0" alt="" />
+  </noscript>
+  {% endif %}
+    
 </body>
 
 
--- a/theme/templates/piwik.html	Sat Oct 19 00:32:18 2019 +0200
+++ b/theme/templates/piwik.html	Mon Oct 21 18:20:59 2019 +0200
@@ -8,9 +8,9 @@
 document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));
 </script><script type="text/javascript">
 try {
-var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", {{ PIWIK_SITE_ID }});
+var piwikTracker = Piwik.getTracker(pkBaseURL + "matomo.php", {{ PIWIK_SITE_ID }});
 piwikTracker.trackPageView();
 piwikTracker.enableLinkTracking();
 } catch( err ) {}
-</script><noscript><p><img src="http://{{ PIWIK_URL }}/piwik.php?idsite={{ PIWIK_SITE_ID }}" style="border:0" alt="" /></p></noscript>
+</script><noscript><p><img src="http://{{ PIWIK_URL }}/matomo.php?idsite={{ PIWIK_SITE_ID }}" style="border:0" alt="" /></p></noscript>
 {% endif %}

mercurial