icefoganalytics / student-financial-aid

Student Financial Aid (SFA)
0 stars 0 forks source link

Add Matomo Analytics to Portal #1

Open datajohnson opened 1 year ago

datajohnson commented 1 year ago

Get tracking code from Lee and use some sort of Vue3 Matomo tracker hosted by eServices.

We need to track basic application usage and statistics.

I believe there are Vue3 libraries that will handle router integration, but we will need to do a little testing to ensure it works correctly. Generally this will be page views, but maybe we want to track certain button clicks as well.

datajohnson commented 1 year ago

I have requested the tracker code from Lee for the test instance.

From eService:

Feel free to delete the comments and minify.
If you have a pre-built Matomo/Piwik component it should just need our Matomo URL (https://analytics.gov.yk.ca/) and site ID (4).
For production everything stays the same but the site ID (on lines 10 and 15 above) changes to 82.
datajohnson commented 1 year ago
<!-- 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://analytics.gov.yk.ca/";
    _paq.push(['setTrackerUrl', u+'matomo.php']);
    _paq.push(['setSiteId', '4']);
    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>
<noscript><p><img src="[https://analytics.gov.yk.ca/matomo.php?idsite=4&amp;rec=1](https://analytics.gov.yk.ca/matomo.php?idsite=4&rec=1)" style="border:0;" alt="" /></p></noscript>
<!-- End Matomo Code -->