diff --git a/README.md b/README.md index e4121f4..dd2545e 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Features - Social Links - Disqus Comments (optional) - Facebook Comments (optional) -- Google Analytics +- Google Analytics and Matomo - Built-in Search - Related Posts - Per Post Navigation (previous and next post) diff --git a/config/config.ini.example b/config/config.ini.example index 0161ec6..dfa991f 100644 --- a/config/config.ini.example +++ b/config/config.ini.example @@ -55,9 +55,18 @@ google.wmt.id = "" ; Google+ publisher google.publisher = "" +; -- Analytics -- +analytics = "" +; "google" or "matomo" + ; Google analytics google.analytics.id = "" +; Matomo config +matomo.url = "" +matomo.siteid = "" +; rules for matomo.url: it should start with "://" and end with "/" + ; Google reCaptcha ; https://www.google.com/recaptcha/admin. Options "false" and "true" diff --git a/system/admin/views/layout.html.php b/system/admin/views/layout.html.php index 92ffc77..40a3da4 100644 --- a/system/admin/views/layout.html.php +++ b/system/admin/views/layout.html.php @@ -57,6 +57,6 @@ - + \ No newline at end of file diff --git a/system/includes/functions.php b/system/includes/functions.php index 9e8cfd6..9c84d52 100644 --- a/system/includes/functions.php +++ b/system/includes/functions.php @@ -1942,27 +1942,51 @@ function publisher() // Google Analytics function analytics($analyticsDir = null) { - $analytics = config('google.analytics.id'); - if ($analyticsDir === null) { - $analyticsDir = '//www.google-analytics.com/analytics.js'; - } else { - $analyticsDir = site_url() . 'themes/' . $analyticsDir . 'analytics.js'; - } - $script = << - (function (i,s,o,g,r,a,m) {i['GoogleAnalyticsObject']=r;i[r]=i[r]||function () { - (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), - m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) - })(window,document,'script','{$analyticsDir}','ga'); - ga('create', '{$analytics}', 'auto'); - ga('send', 'pageview'); - + if (config("analytics") == "google") { + $analytics = config('google.analytics.id'); + if ($analyticsDir === null) { + $analyticsDir = '//www.google-analytics.com/analytics.js'; + } else { + $analyticsDir = site_url() . 'themes/' . $analyticsDir . 'analytics.js'; + } + $script = << + (function (i,s,o,g,r,a,m) {i['GoogleAnalyticsObject']=r;i[r]=i[r]||function () { + (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), + m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) + })(window,document,'script','{$analyticsDir}','ga'); + ga('create', '{$analytics}', 'auto'); + ga('send', 'pageview'); + EOF; + } elseif (config("analytics") == "matomo") { + $analytics = config('matomo.siteid'); + $analyticsDir = config('matomo.url'); + + $script = << + var _paq = window._paq || []; + _paq.push(["setDocumentTitle", document.domain + "/" + document.title]); + _paq.push(['trackPageView']); + _paq.push(['enableLinkTracking']); + (function() { + var u="{$analyticsDir}"; + _paq.push(['setTrackerUrl', u+'matomo.php']); + _paq.push(['setSiteId', '{$analytics}']); + 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); + })(); + + +EOF; + } + if (!empty($analytics)) { return $script; } } + // Menu function menu($custom = null) { diff --git a/themes/blog/layout.html.php b/themes/blog/layout.html.php index cd9f1ef..a3ee711 100644 --- a/themes/blog/layout.html.php +++ b/themes/blog/layout.html.php @@ -197,6 +197,6 @@ - + \ No newline at end of file diff --git a/themes/clean/layout.html.php b/themes/clean/layout.html.php index 7509864..010f787 100644 --- a/themes/clean/layout.html.php +++ b/themes/clean/layout.html.php @@ -50,6 +50,6 @@
- + \ No newline at end of file diff --git a/themes/default/layout.html.php b/themes/default/layout.html.php index ea9f88a..a5b6da4 100644 --- a/themes/default/layout.html.php +++ b/themes/default/layout.html.php @@ -82,6 +82,6 @@ - + \ No newline at end of file diff --git a/themes/logs/layout.html.php b/themes/logs/layout.html.php index 270a8e3..d35ee78 100644 --- a/themes/logs/layout.html.php +++ b/themes/logs/layout.html.php @@ -97,6 +97,6 @@ - + \ No newline at end of file diff --git a/themes/twentyfifteen/layout.html.php b/themes/twentyfifteen/layout.html.php index 98125e5..f8f04b4 100644 --- a/themes/twentyfifteen/layout.html.php +++ b/themes/twentyfifteen/layout.html.php @@ -135,6 +135,6 @@ - + diff --git a/themes/twentysixteen/layout.html.php b/themes/twentysixteen/layout.html.php index aa46009..6a8a140 100644 --- a/themes/twentysixteen/layout.html.php +++ b/themes/twentysixteen/layout.html.php @@ -159,6 +159,6 @@ /* ]]> */ - + \ No newline at end of file