Other platforms
Add Loogika to Moodle
You add Loogika to Moodle through the Additional HTML setting in the site administration. Paste the script tag into the Within HEAD field. Moodle then adds the tag to every page, and you do not touch the theme.
Last updated .
What do you need before you start?
Copy your script tag from Site Settings in Loogika, under the Tracking Script tab. It looks like this, with your own 12-character site ID in place of YOUR_SITE_ID:
<script src="https://app.loogika.com/api/script.js?siteId=YOUR_SITE_ID" defer></script>
You also need an administrator account on the Moodle site.
How do you add the Loogika tag in Moodle?
- Log in as an administrator. Go to Site administration, then Appearance, then Additional HTML.
- Paste the script tag into the Within HEAD field.
- Click Save changes.
The tag now loads on every page of the site. That includes course pages, activities and the login page.
The browser of each user fetches the script directly from app.loogika.com. Moodle does not pass the request through its own server. Users must be able to reach that address from their network.
How do you track clicks in a Moodle course?
Add the attribute data-loogika-event to a link or a button. Moodle renders standard HTML, so the attribute works wherever you control the markup. An HTML block on a course page and a label are two such places.
<button data-loogika-event="course_open" data-loogika-prop-course="42">
Open course
</button>
A click on this button sends the event course_open with the property course. The events page explains names, properties and limits.
How do you send events for enrolment or completion?
Write a short piece of JavaScript that calls window.loogika.event(). Place that code in the When BODY is closed field, which sits on the same Additional HTML page as Within HEAD.
How do you check that Loogika is installed?
Load your Moodle site in a fresh browser tab and visit a few pages. The pageviews show up in the Loogika dashboard within a few seconds. If nothing arrives, open the page source and look for script.js?siteId=.
Why does Moodle not send data to Loogika?
| Problem | Cause and fix |
|---|---|
| The tag is saved and missing from the page source | Moodle caches the pages it renders. Go to Site administration, then Development, then Purge caches, and reload the page |
| Loogika does not track pages inside the Moodle mobile app | Course content in the Moodle app appears in a WebView that belongs to the app and has its own pages. Only the website picks up the Additional HTML setting |
| The tag was pasted into a theme setting | Theme settings such as Raw SCSS in the Boost theme only accept styles. A script tag belongs in Additional HTML |