On this page
Before you start
There is no CookieScan plugin for WordPress. You add the CookieScan install code to the <head> of every page, with a header plugin or in your theme.
You need:
- your install code, from Cookie Banner, then Install Code, then Manual Install
- a WordPress administrator account that can add plugins or edit theme files
If you manage your tags in Google Tag Manager, follow Install with Google Tag Manager instead. You don't need either method below.
Add the code with WPCode
WPCode is a free plugin that adds code to your website's header. Other header plugins work the same way. A theme update can't remove code you add this way.
Install the WPCode plugin
In WordPress, go to Plugins and select Add New Plugin. Search for WPCode, select Install Now, then Activate.
Open Header & Footer
Go to Code Snippets, then Header & Footer.
Paste the install code
Paste your install code into the Header box.
Save the change
Select Save Changes.
The install code looks like this:
<script src="https://banner.cookiescan.com/js?id=YOUR-COOKIESCAN-ID"></script>Add the code in your theme
You can add the code in your theme's functions.php file instead. Use a child theme, so a theme update doesn't remove your change.
Warning: Back up first
A mistake in functions.php can stop your website loading. Keep a copy of the file before you change it.
Open your child theme's functions.php
Use your hosting file manager, or the theme file editor in WordPress.
Add the code below
Paste it at the end of the file, with your CookieScan ID in place of
YOUR-COOKIESCAN-ID.Save the file
Save it, then check your website still loads.
function cookiescan_banner_script() {
?>
<script src="https://banner.cookiescan.com/js?id=YOUR-COOKIESCAN-ID"></script>
<?php
}
add_action( 'wp_head', 'cookiescan_banner_script', 1 );The 1 at the end puts the CookieScan script near the top of <head>, before most other scripts.
Keep CookieScan first and up to date
WordPress plugins can move, delay or cache scripts. Check these after you add the code:
- Other plugins may add scripts above CookieScan. View your page's source and check that the CookieScan script comes first in
<head>. - If a performance plugin delays, defers or combines JavaScript, exclude
banner.cookiescan.comfrom it. - Clear your caching plugin's cache, and any CDN cache, so visitors get the new page.
Auto-blocking can only hold back scripts that load after CookieScan. See Tags fire before visitors consent.
Check it worked
Open your website in a private browser window. Your cookie banner appears within a few seconds. Make a choice, then check that the Dashboard shows Receiving consents. See Check your banner is working.