Joomla implementation

Please note: This article was originally drafted to help implement Cookiebot prior to the release of the automated cookie control functionality on September 10th 2019.
You may still be using and preferring the manual implementation and markup option. In that case this article may still be relevant for you.


For automatic cookie blocking make sure that your cookie consent banner script includes the data attribute data-blockingmode=”auto” and that “async” is removed from the script example below.

Implementing the cookie banner

Add your personal Cookiebot consent script to your template’s index.php file within the head tag and before the jdoc head tag (<jdoc:include type=”head”/>)

Example:

<head>
<script id="CookieConsent" src="https://consent.cookiebot.com/uc.js" data-cbid="00000000-0000-0000-0000-000000000000" type="text/javascript" async></script>
 <jdoc:include type="head"/>
</head>

As an alternative you could inject the script on all pages with the add script function:

$cookieTag .= '<script id="CookieConsent" src="https://consent.cookiebot.com/uc.js" data-cbid="00000000-0000-0000-0000-000000000000" type="text/javascript" async></script>';
$document = JFactory::getDocument();
$document->addCustomTag($cookieTag);

Implementing Prior Consent on Joomla plugins, extensions, components and modules

To enable prior consent, you need to add the “data-cookieconsent” attribute to all the scripts tags setting cookies. Set the comma-separated value of the attribute to one or more of the three types of cookies: “preferences”, “statistics” and “marketing” in accordance with the types of cookies being set by each script. Finally change the script tag attribute “type” from “text/javascript” to “text/plain”. 

Example with Asynchronous Google Analytics plugin:

dit the plugin code directly by going to the root file (eg. joomla2.5) -> plugin -> select the plugin file “GoogleAnalytics.php” and edit it.

If you are using traditional Google Analytics make the following change to the code:

$javascript .= "<script type=\"text/javascript\">

Becomes:

$javascript .= "<script type=\"text/plain\" data-cookieconsent=\"statistics"\>

If you use Google Analytics Universal :

<script>
 (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
 (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
 m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
 })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

becomes:

<script type="text/plain" data-cookieconsent="statistics">
 (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
 (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
 m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
 })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

Displaying the cookie declaration on a specific Joomla page

If you want to display the cookie declaration on a separate page or as a part of your privacy policy, embed your cookie declaration script tag as described below.

In the content editor for the page or article where you want to show your cookie declaration in full, switch to html view mode and paste the script code where you want the declaration to show, e.g.:

<script id="CookiePolicy" src="https://consent.cookiebot.com/00000000-0000-0000-0000-000000000000/cd.js" type="text/javascript" async></script>

If you are using  a rich text/WYSIWYG editor,the script above may be stripped out when saving the page. To avoid this behaviour you need to enable Javascript in the editor.

30 day free trial Cookiebot

Cookie scanner, cookie banner, cookie declaration en cookie consent in one solution.

  • Use cookies on your website compliant with GDPR, ePrivacy and cookie legislation
  • Cookie management completely automated
  • Cookie banner based on your corporate identity
  • Automatic composed cookie declaration, always up to date

The Cookiebot solution runs on 500,000+ websites, manages 13 billion User Consents and supports 40+ languages.