|
|
|
@ -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 = <<<EOF |
|
|
|
<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'); |
|
|
|
</script> |
|
|
|
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 = <<<EOF |
|
|
|
<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'); |
|
|
|
</script> |
|
|
|
EOF; |
|
|
|
} elseif (config("analytics") == "matomo") { |
|
|
|
$analytics = config('matomo.siteid'); |
|
|
|
$analyticsDir = config('matomo.url'); |
|
|
|
|
|
|
|
$script = <<<EOF |
|
|
|
<script type="text/javascript"> |
|
|
|
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); |
|
|
|
})(); |
|
|
|
</script> |
|
|
|
<noscript><p><img src="{$analyticsDir}matomo.php?idsite={$analytics}&rec=1" style="border:0;" alt="" /></p></noscript> |
|
|
|
EOF; |
|
|
|
} |
|
|
|
|
|
|
|
if (!empty($analytics)) { |
|
|
|
return $script; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Menu
|
|
|
|
function menu($custom = null) |
|
|
|
{ |
|
|
|
|