WordPress installation

Please note that this is no longer being updated. Kindly visit the new Cookiebot support area (https://support.cookiebot.com/hc/en-us) for updated guides, articles and FAQs. If you do not find the answer to your question there, you are welcome to post it in the Cookiebot community (https://support.cookiebot.com/hc/en-us/community/topics).

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 (available under the tab "Your scripts" in the Cookiebot Manager) 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(); ?>>
<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(); ?>

When saved, the cookie consent banner will display on your website.

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

<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,

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

Feedback and Knowledge Base