Documentation menuContent management systems: Joomla

Content management systems

Add Loogika to Joomla

Joomla has no built-in setting for header code. You add the Loogika script with a Custom module that is assigned to every page, or in the index.php file of your template. The module method needs no file edits and survives template updates.

Last updated .

What do you need before you start?

Copy your site ID from Site Settings in Loogika, under the Tracking Script tab. The same tab shows the full script tag, which looks like this:

<script src="https://app.loogika.com/api/script.js?siteId=YOUR_SITE_ID" defer></script>

How do you add Loogika with a Custom module?

Create a Custom module that holds a small loader script. Templates rarely offer a module position inside the head. Wherever the module sits on the page, the loader places the Loogika script in the head.

  1. Go to Content, then Site Modules, in the Administrator panel. On Joomla 3 the path is Extensions, then Modules. Click New and choose Custom.
  2. Set Title to Loogika and Show Title to Hide. Set Position to any position that your template renders on every page.
  3. Click the Toggle Editor button, or switch to Code view, so the editor does not strip the script. Paste the code below and replace YOUR_SITE_ID.
  4. Set Status to Published and choose On all pages under Menu Assignment. Click Save & Close.
<script>
(function () {
  var s = document.createElement("script");
  s.src = "https://app.loogika.com/api/script.js?siteId=YOUR_SITE_ID";
  s.defer = true;
  document.head.appendChild(s);
})();
</script>

How do you add Loogika in the template file?

Paste the script tag into index.php of your active template, just before the closing </head> tag. Make the edit in a child template, which Joomla supports from version 4.1, or in a copy of the template that you own. A template update otherwise overwrites the change.

  1. Go to System, then Site Templates. Select the template that is active on your site.
  2. In index.php, place the tag before </head>, as shown below.
  3. Click Save & Close.
<script src="https://app.loogika.com/api/script.js?siteId=YOUR_SITE_ID" defer></script>
</head>

How do you check that Loogika is installed?

Load your site in a fresh browser tab and visit a few pages. The pageviews appear in the Loogika dashboard within a few seconds. If nothing arrives, open the page source and look for script.js?siteId=.

Why does Joomla not send data to Loogika?

CauseFix
The module is not on the pageCheck that the module is published and assigned to On all pages, and that its position exists in your template. Then go to System, then Clear Cache
TinyMCE strips the scriptSave the module with the editor toggled off. You can also open the Editor - TinyMCE plugin under System, then Plugins. In its Extended Valid Elements field, enter script[src|defer]. On Joomla 3 the plugins sit under Extensions, then Plugins
The page cache serves old HTMLThe System - Page Cache plugin stores finished pages. Clear the cache after you add the script

The page cache in Joomla does not stop tracking once the script is on the page. The script runs in the visitor's browser, so it also records views of cached pages.