NEW! Use the Cookiebot WordPress plugin: https://wordpress.org/plugins/cookiebot/
Manual installation of Cookiebot without using the 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. (marked in bold):
<!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>
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 the tag attribute "data-cookieconsent". 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 behaviour you need to turn off the rich text editor (from the dashboard, go to Users > Your Profile > Personal Options) while editing the page.
Comments
0 comments
Article is closed for comments.