This guide will show you how to manually install Cookiebot without using the plugin. If you would rather use the Cookiebot WordPress plugin, you can find it here: Cookiebot Wordpress plugin
Implementing the Cookiebot consent dialog in a WordPress site:
Add your personal Cookiebot script for the consent dialog. Your script is available in the Cookiebot manager under "Your scripts". Please choose whether you want to use automatic blocking mode or manual blocking mode. Add your preferred script to the WordPress theme file "header.php" inside the
<head>
tag and before the wp_head()
call, e.g.:<!DOCTYPE html> <html <?php language_attributes(); ?>> <head> <title><?php wp_title(); ?></title> <link rel="stylesheet" href="<?php echo get_stylesheet_uri(); ?>" type="text/css" media="screen" /> <script id="Cookiebot" src="https://consent.cookiebot.com/uc.js" data-cbid="00000000-0000-0000-0000-000000000000" type="text/javascript" async></script> <?php wp_head(); ?> </head>
The example above is for the manual implementation of prior consent.
When saved, the cookie consent banner will display on your website. If you have used Automatic Cookie Blocking Mode you may skip ahead to Showing your cookie declaration in full on a separate WordPress page or post.
Manually implementing prior consent on plugins:
To hold back plugin-cookies until the visitor has consented, script tags within the plugin must be marked up with thedata-cookieconsent
tag attribute. The value of this attribute must be set to one or more of the following values (comma-separated) which must reflect the type(s) of cookies being set by the script tag: preferences, statistics, marketing. Finally the type
attribute of the script tag must be set or changed to text/plain
(highlighted in bold).Example:
<script type="text/plain" data-cookieconsent="marketing" src="http://s7.addthis.com/js/250/addthis_widget.js" ></script>In WordPress, script tags may also load from plugins with the function wp_enqueue_script. In that case you can make the necessary modifications to the script tag using the filter script_loader_tag.
PHP plugin example:
wp_enqueue_script('addthis_widget.js', $script); add_filter('script_loader_tag', function ($tag, $handle) { if ('addthis_widget.js' !== $handle) return $tag; $tagstring = str_replace('text/javascript', 'text/plain', $tag); $tagstring = str_replace(' src', ' data-cookieconsent="marketing" src', $tagstring); return $tagstring; }, 10, 2 );
Showing your cookie declaration in full on a separate WordPress page or post:
If you want to show your cookie declaration in full on a seperate page or as part of your privacy policy, embed your cookie declaration script as described below.
In the content editor for the page or post where you want to show your cookie declaration in full, switch to text view mode and paste the script code where you want the declaration to show, e.g.:
In the content editor for the page or post where you want to show your cookie declaration in full, switch to text view mode and paste the script code where you want the declaration to show, e.g.:
<script id="CookieDeclaration" src="https://consent.cookiebot.com/00000000-0000-0000-0000-000000000000/cd.js" type="text/javascript" async ></script>If you are using a version of WordPress older than version 4 and if you are using the rich text editor, the
src
attribute of the script above may be stripped out when saving the page or post. To avoid this behavior you need to turn off the rich text editor (from the dashboard, go to Users → Your Profile → Personal Options) while editing the page.Want to know more about Cookiebot CMP for WordPress?
Read more: WordPress, cookies, plugins and GDPR: What’s the deal?
Comments
0 comments
Please sign in to leave a comment.