hyperglass icon indicating copy to clipboard operation
hyperglass copied to clipboard

Matomo tracking code

Open Ciacho opened this issue 4 years ago • 2 comments

Feature Description

I am asking for the possibility of adding my own html / js code for user tracking. I use the Matomo application - under my own URL and a changed tracking path - because customers mostly block Google Analytics anyway :)

For example tracking code on JavaScript

<!-- 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://FQDN/";
    _paq.push(['setTrackerUrl', u+'FILE.php']);
    _paq.push(['setSiteId', '4']);
    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
    g.async=true; g.src=u+'FILE.js'; s.parentNode.insertBefore(g,s);
  })();
</script>
<!-- End Matomo Code -->

Tracking over image:

<!-- Matomo Image Tracker-->
<img referrerpolicy="no-referrer-when-downgrade" src="https://FQDN/FILE.php?idsite={NUMBER}&amp;rec=1" style="border:0" alt="" />
<!-- End Matomo -->

FQDN, FILE and NUMBER are individually set (I don't use the standard ones Matomo proposes;)

Is your feature request related to a problem? Please describe.

Environment & Use Case

Additional Context

Ciacho avatar Nov 29 '21 12:11 Ciacho

This will be available in the release of 2.0. So you're aware of the implementation details, you'll be able to define custom files like this in config.yaml (currently hyperglass.yaml):

web:
    custom_javascript: <path to your custom js>
    custom_html: <path to your custom html>

The JS will be added inline via a <script/> tag.

The HTML will be nested under a <div/> element adjacent to <div id="__next"/>.

If neither is defined, no custom element is added.

thatmattlove avatar Dec 09 '21 00:12 thatmattlove

Great news, thank you :)

I'm waiting for the 2.0 version to be produced :)

Ciacho avatar Dec 09 '21 10:12 Ciacho