techno-tim / littlelink-server

A lightweight, open source, stateless, and self-hosted alternative to linktree in a Docker container!
https://links.technotim.live
MIT License
921 stars 162 forks source link

Matamo analytics support? #41

Closed samip5 closed 2 years ago

samip5 commented 3 years ago

Please add support for Matamo (https://matomo.org).

tomajask commented 3 years ago

How about just allowing to add some custom code into <head></head> section. Then one change will allow to use whatever analytics tool you want.

samip5 commented 3 years ago

That would work too.

timothystewart6 commented 3 years ago

Thanks. The goal of the docker container is to keep it simple. Currently Google analytics is as simple as adding your tracking Id, then analytics and button clicks are wired up automatically. I'd like to do the same for any additional analytics system that is added, rather than injecting scripts via env variable.

timothystewart6 commented 3 years ago

I am happy to write this integration but I have no easy way of testing it, outside of hosting/creating my own account

samip5 commented 3 years ago

This is the code for Matamo:

<!-- Matomo -->
<script type="text/javascript">
    var _paq = window._paq || [];
    /* tracker methods like "setCustomDimension" should be called before "trackPageView" */
    _paq.push(['trackPageView']);
    _paq.push(['enableLinkTracking']);
    (function () {
        var u = "//samip.fi/matomo/";
        _paq.push(['setTrackerUrl', u + 'matomo.php']);
        _paq.push(['setSiteId', '1']);
        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>
<!-- Image Tracker-->
<img src="https://samip.fi/matomo/matomo.php?idsite=1&amp;rec=1" style="border:0" alt=""/>
<!-- End Matomo Code -->

SiteID and the URL to the matomo instance is the most things it would need.

kenjibailly commented 2 years ago

Any progress on this? :)

timothystewart6 commented 2 years ago

@kenjibailly nope but PRs are welcome! In my experience, the person that cares about it most will add this feature.

kenjibailly commented 2 years ago

I def want to look on how to implement it, but I'm just a hobbyist coder and have no idea how you link your variables to docker. Some pointers would help me out try to make it happen :)

kenjibailly commented 2 years ago

I figured it out and made a pull request for this here: #111

Edit: added image tracking in #112

timothystewart6 commented 2 years ago

closed by https://github.com/techno-tim/littlelink-server/pull/112