Closed oupala closed 1 year ago
I don't use analytics, or at least since many many years, so I want to be sure of the need here.
Would the following feature be enough ?
Matomo offer several solutions for tracking website activity:
u
matomo server url, and the siteId
site id):<!-- Matomo -->
<script>
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="https://matomo.server.url/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '42']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<!-- End Matomo Code -->
<!-- Matomo Image Tracker-->
<img referrerpolicy="no-referrer-when-downgrade" src="https://matomo.server.url/matomo.php?idsite=42&rec=1" style="border:0" alt="" />
<!-- End Matomo -->
I think that it would be great to propose at least the two first solutions, that are widely used among all analytics solutions.
For example, lutim is offering the image tracking solution as a configuration entry in the configuration file. The integration made by lutim is interesting as you only have to enter the image tracking url, and not the whole img src
tag. But the drawback is that you can't choose between the image tracking or the javascript code.
That's why I think that the solution that you propose is a bit more complicated for average user, but more powerful and versatile. Note that the solution should be available for docker users (and as well available as a docker en var), but also to raw html users (with or without a yran build, users should be able to find a placeholder and to replace it by a javascript script, or by an image tracking tag).
I don't like having to depend on "the latest way to include analytics info" from "the latest tool". I do understand the problem of ease of use.
I'll try to implement a mixed solution to have as much as possible no dependency on matomo or another specific tool, and still have something "not too complex" to configure...
Also, the kroki engine URL is currently configurable threw a config file, that file being patched when the docker container is started, or just editable when used as a simple static site. There is no reason to not do that for any other configuration value, so any configuration will be both configurable using DOCKER env or config file.
The solution I envisage:
window.config = {
krokiEngineUrl: 'https://kroki.io/',
analytics: {
content: '',
provider: 'matomo_js',
data: [ 'https://matomo.server.url/', '42' ]
},
};
window.analytic_providers_config = {
matomo_js: `
<!-- Matomo -->
<script>
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="{1}";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '{2}']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<!-- End Matomo Code -->
`,
matomo_image: `
<!-- Matomo Image Tracker-->
<img referrerpolicy="no-referrer-when-downgrade" src="{1}matomo.php?idsite={2}&rec=1" style="border:0" alt="" />
<!-- End Matomo -->
`,
google: `
<!-- [...] -->
`,
};
That way, the niolesk process don't have to know the providers. Only the providers configuration file is needed. That file can be edited by power user. For docker, that file can be overriden with -v on the file itself.
The whole content of the HTML analytics block can passed in the "content" var/field, overiding everything else.
That would be great!
And this solution seems brilliant!
Coded that, but doesn't work : javascript "script" tag can't be included at runtime like any block of html, because of security considerations.
I'm rewriting a slyghly more complex version where code should be either html block or script. (It does work if inclusion is done on server side, but not at runtime)
Hello !
Now, it's done... at least on the dedicated branch. Spec has changed a bit, as Githubissues.
I think it would be cool to allow the integration of an analytic tag (such as matomo) to the docker image of niolesk.
It could be cool to add a parameter to the Docker image to add an analytic tag at runtime, when launching the container.