Add analytics to studio

@regis Hello i would like to ask how can i add google analytics at studio cms
I used plugin for tutor


Deploy custom ones

eg. (for custom certificates ).

  • run tutor plugins printroot to check where TUTOR_PLUGINS_ROOT are installed, default is ~/.local/share/tutor-plugins
  • add the YAML file custom_cert.yml under ~/.local/share/tutor-plugins :
# cp custom_cert.yml /root/.local//share/tutor-plugins
  • install the plugin: tutor plugins install custom_cert.yml
  • enable it: tutor plugins enable customcert
  • save the config: tutor config save
  • restart tutor: tutor local reboot -d

AS you enabling the plugin does not require rebuilding the image or even reconfiguring with tutor local quickstart , hence the simple turor local reboot -d .

Enabling the plugin updates itself the Tutor’s config.yml :

- customcert
WEB_PROXY: false

Even more interesting is enabling Analytics! as a plugin (Tutor covers Google Analytics :

Matomo Analytics for our MOOC.

  • created in as Mooc-DEV with SiteId: 34 .
  • tracking code :
<!-- Matomo -->
<script type="text/javascript">
  var _paq = window._paq = window._paq || [];
  /* tracker methods like "setCustomDimension" should be called before "trackPageView" */
  _paq.push(["setDocumentTitle", document.domain + "/" + document.title]);
  _paq.push(["setCookieDomain", "*"]);
  _paq.push(["setDomains", ["*"]]);
  (function() {
    var u="";
    _paq.push(['setTrackerUrl', u+'matomo.php']);
    _paq.push(['setSiteId', '34']);
    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
    g.type='text/javascript'; g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
<noscript><p><img src=";rec=1" style="border:0;" alt="" /></p></noscript>
<!-- End Matomo Code -->
  • create our own matomo plugin :
    • matomo.yml :
name: matomoanalytics
version: 0.1.0
  openedx-common-settings: |
    # googleanalytics special settings

and install it in /root/.local/share/tutor-plugins .

  • enable it with :
    • tutor plugins enable matomoanalytics
    • tutor config save
  • check it is enabled with :
# turor plugins list
xqueue==10.1.0 (disabled)

and also with:

# grep -ril MATOMO /root/.local/share/tutor/env/apps/openedx/settings/

and see that indeed the MATOMO_ANALYTICS_SITE_ID is indeed in the settings files, eg.

[]:~/.local/share/tutor/env/apps/openedx/settings# grep MATOMO lms/
  • restart the platform
    • tutor local quickstart
  • or rahter rebuild the local image : turor local build openedx .

After that i’ve inserted the script at footer.html in lms and it works on lms

Where should i add the same script at cms?

Thank you in advance

Hi @stefanidi! Thanks for posting a detailed description :slight_smile: I have never added analytics to the CMS myself, but it seems to me that you should modify the cms/templates/base.html file.