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”/>)


<script id="CookieConsent" src="" data-cbid="00000000-0000-0000-0000-000000000000" type="text/javascript" async></script>
 <jdoc:include type="head"/>

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

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

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\">


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

If you use Google Analytics Universal :

 (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),


<script type="text/plain" data-cookieconsent="statistics">
 (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),

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="" 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.