Mamoto Analytics theme component

This commit is contained in:
Kyle Zhao 2018-10-22 22:20:33 -04:00
parent 19d13ecc86
commit 980416d6d7
4 changed files with 35 additions and 0 deletions

6
about.json Normal file
View File

@ -0,0 +1,6 @@
{
"name": "Matomo Analytics",
"about_url": "https://meta.discourse.org/t/how-to-enable-matomo-analytics-on-discourse/33090",
"license_url": "https://github.com/discourse/discourse-matomo-analytics/blob/master/LICENSE",
"component": true
}

11
common/body_tag.html Normal file
View File

@ -0,0 +1,11 @@
<script type="text/discourse-plugin" version="0.8">
window._paq = window._paq || [];
window._paq.push(["enableLinkTracking"]);
(function() {
var u=(("https:" == document.location.protocol) ? "https" : "http") + "://" + settings.host_url;
window._paq.push(["setTrackerUrl", u+"piwik.php"]);
window._paq.push(["setSiteId", settings.website_id]);
var d=document, g=d.createElement("script"), s=d.getElementsByTagName("script")[0]; g.type="text/javascript";
g.defer=true; g.async=true; g.src=u+"piwik.js"; s.parentNode.insertBefore(g,s);
})();
</script>

11
common/head_tag.html Normal file
View File

@ -0,0 +1,11 @@
<script type="text/discourse-plugin" version="0.2">
api.onPageChange((url, title) => {
if (window._paq) {
const currentUser = api._currentUser;
window._paq.push(['setCustomVariable', 1, 'Anonymous', !currentUser, 'visit']);
window._paq.push(["setCustomUrl", url]);
window._paq.push(["setDocumentTitle", title]);
window._paq.push(["trackPageView"]);
}
});
</script>

7
settings.yml Normal file
View File

@ -0,0 +1,7 @@
host_url:
type: string
default: ''
description: Host URL without http:// or https://
website_id:
type: string
default: ''