1
0
Fork 0
mirror of https://github.com/Findus23/guides.git synced 2024-09-19 16:03:51 +02:00

simplify Matomo

This commit is contained in:
Lukas Winkler 2022-12-21 00:15:38 +01:00
parent e8fef4ca7c
commit 57e5ad2779
Signed by: lukas
GPG key ID: 54DE4D798D244853
6 changed files with 64 additions and 23 deletions

1
.gitignore vendored
View file

@ -8,3 +8,4 @@ hugo_stats.json
themes/
hugo
node_modules/

17
assets/js/main.js Normal file
View file

@ -0,0 +1,17 @@
import {MatomoLiteTracker} from "matomo-lite-tracker/src/tracker"
import {PerformanceMetric} from "matomo-lite-tracker/src/performancetracking"
import {BrowserFeatures} from "matomo-lite-tracker/src/browserfeatures"
import {enableLinkTracking} from "matomo-lite-tracker/src/linktracking"
import {isDoNotTrackEnabled} from "matomo-lite-tracker/src/util"
if (!isDoNotTrackEnabled()) {
const m = new MatomoLiteTracker("https://matomo.lw1.at", 28)
m.performanceMetric = new PerformanceMetric()
m.browserFeatures = new BrowserFeatures()
enableLinkTracking(m, [])
m.trackPageview()
}

View file

@ -15,8 +15,6 @@
{{- $sassOptions := (dict "outputStyle" "compressed" "enableSourceMap" true) }}
{{ $style := resources.Get "sass/main.scss" | resources.ToCSS $sassOptions | resources.Fingerprint }}
<link rel="stylesheet" href="{{ $style.Permalink }}" integrity="{{ $style.Data.Integrity }}">
{{ partial "matomo.html" . }}
</head>
<body>
<main>
@ -27,6 +25,9 @@
<a href="https://lw1.at/i/">Privacy Policy</a>
<a href="https://lw1.at/">My other projects</a>
</footer>
{{- $esBuildOptions := (dict "minify" true "sourceMap" "external") }}
{{- $built := resources.Get "js/main.js" | js.Build $esBuildOptions | resources.Fingerprint }}
<script src="{{ $built.RelPermalink }}" defer async integrity="{{ $built.Data.Integrity }}"></script>
</body>
</html>

View file

@ -1,21 +0,0 @@
<!-- Matomo -->
<script type="text/javascript">
var _paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(["setDoNotTrack", true]);
_paq.push(['disableCookies']);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function () {
var u = "https://matomo.lw1.at/";
_paq.push(['setTrackerUrl', u + 'matomo.php']);
_paq.push(['setSiteId', '28']);
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 -->

21
package-lock.json generated Normal file
View file

@ -0,0 +1,21 @@
{
"name": "guides",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "guides",
"version": "1.0.0",
"license": "ISC",
"dependencies": {
"matomo-lite-tracker": "github:Findus23/MatomoLiteTracker"
}
},
"node_modules/matomo-lite-tracker": {
"version": "1.0.0",
"resolved": "git+ssh://git@github.com/Findus23/MatomoLiteTracker.git#eda41aac10eeb3643ceb0cfb0b5a5e91a8d1bbd5",
"license": "BSD-3-Clause"
}
}
}

22
package.json Normal file
View file

@ -0,0 +1,22 @@
{
"name": "guides",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Findus23/guides.git"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/Findus23/guides/issues"
},
"homepage": "https://github.com/Findus23/guides#readme",
"dependencies": {
"matomo-lite-tracker": "github:Findus23/MatomoLiteTracker"
}
}