Info
Content

Mahara and Google Analytics


You can add the Google Analytics script snippet to a configuration parameter called additionalhtmlhead (you also have the option of using additionalhtmltopofbody and additionalhtmlfooter).

For example in your config.php you can add something like this, which is the Google Analytics tracking code used by this site:

$cfg->additionalhtmlhead = "
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-144211591-1"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'UA-144211591-1');
</script>
";

This, and many other configuration settings and examples can be found in your Mahara installation under /lib/config-defaults.php

No Comments
Back to top