Implementation

Setting up CookieOfficer on Joomla

Adding the CookieOfficer code on the Joomla platform.

4 min read

On Joomla, you add the CookieOfficer code with an extension that inserts code into the header, or directly in the template file. The first method doesn't require editing any files; the second gives you full control over the order of scripts. After either of them you need to clear the cache, because Joomla caches the generated pages and, until the cache is cleared, serves a version without our code.

We give the names of items in the Joomla panel in English, because in many installations Joomla remains untranslated.

Before you start

Copy the code from the Installation page in the CookieOfficer panel. In the “Deployment method” section, choose “Code on the site”, then in the “Paste the code at the top of <head>” card click “Copy” next to the “CookieOfficer script” block.

You need an account with Joomla administrator permissions.

Method 1: an extension for inserting code

This is the simplest way, and the only one that doesn't require access to the template files.

  1. Go to System > Install > Extensions and install an extension that lets you add your own code to the page header.
  2. Enable it and open its settings.
  3. Paste the CookieOfficer code in the field that corresponds to the <head> section, right at the beginning, before any other scripts.
  4. Save your changes.
  5. Clear the Joomla cache.

If the extension lets you set the order or priority of insertion, choose a setting that places our code before the other tracking tools.

Method 2: the index.php file in a child template

  1. Go to System > Site Templates and open your template.
  2. In the file list, open index.php.
  3. Paste the CookieOfficer code right after the opening <head> tag, before the <jdoc:include type="head" /> call and before any other scripts.
  4. Save the file.
  5. Clear the Joomla cache.

The <jdoc:include type="head" /> tag inserts the stylesheets and scripts of Joomla and its extensions, so code placed after it won't be able to stop them in time.

Work in a child template. Changes in the parent template will be overwritten the next time it is updated, and the banner will disappear from the site without warning. If your version of Joomla doesn't support child templates, duplicate the template before editing it.

Why do you need to clear the cache?

Joomla stores the generated pages and returns them to visitors without reassembling the template. Until the cache is cleared, they see the version from before the change, without our code, and the setup test will fail.

You clear the cache under System > Clear Cache. If you also use additional server-side caching or a performance plugin, clear those too.

How do I verify the setup?

Go back to the Installation page in the CookieOfficer panel and click “Verify now”. If it succeeds, you'll see the heading “Script detected and active”.

Open the site in an incognito window, as a logged-out user. In a regular window your own decision is already saved, and Joomla caches pages differently for logged-in users.

Finally, run a scan of your site in the panel and go to the Cookies page. There should be no message above the list of detected items about trackers running after a visitor has rejected consent.

If something on your site stops working after the setup, go to the Cookies page and, next to that provider's entry, switch “Block before consent” to “Not blocked”. Blocking of the other entries keeps working.

Common mistakes to avoid

  • Don't skip clearing the cache in Joomla. This is the most common cause of failed setups in Joomla. The code is in place, but the site keeps serving the old version.
  • Don't edit the parent template. When the template is updated, your changes will disappear together with the banner.
  • Don't paste the code after <jdoc:include type="head" />. Joomla and extension scripts will then manage to start before our code.
  • Don't mark scripts added by extensions manually. They reach the page through Joomla's own mechanisms, so you can't change them in the template. Holding back such a script takes a two-part change: type must be set to text/plain, and data-co-cat must be added next to it. The attribute alone won't hold anything back.

Didn't find an answer?

Write to us. We reply on working days, usually the same day.

Contact us