Cookie compliance integration for Wordpress and WooCommerce
Cookie compliance integration for Wordpress and WooCommerce
There are two ways of installing CookieScript on WordPress (or WooCommerce): with a plugin or by modifying template file. The Plugin is recommended since you will still be able to update your WordPress theme later.
Method 1: Installing CookieScript via WordPress plugin.
To make your job with Cookie-Script snippet easier and more enjoyable we have created a WordPress plugin. All you need to do is install and follow instructions:
1. Download the plugin from https://wordpress.org/plugins/cookie-script-com/ or find it in your Wordpress dashboard: click on Plugins > Add New. Then type your “Cookie-Script.com” into the search box on the top right and then click Install Now:
2. Go to the Plugins Search “Cookie-Script” and click Activate:
3. Go to the Plugins again, and click Settings under “Cookie-Script.com”:
4. Check the box Enable Google Consent Mode, so you can accept or reject different types of cookies for your cookie banner:
5. Finally, you have to copy-paste the script URL from your Cookie-Script.com account:
CookieScript Plugin Integrates with WP Consent API
What Is the WP Consent API?
The WP Consent API is a shared system in WordPress that lets different plugins and themes talk to each other about user consent.
Instead of each plugin making up its own way to handle things like cookie preferences, this API gives them a common language.
It’s designed to make sure that when a user agrees—or doesn’t agree—to something like marketing or analytics cookies, every part of your site is on the same page.
Why Should You Use It?
With privacy laws like GDPR and CCPA in place, it’s no longer enough to just show a cookie banner and call it a day. Websites also have to make sure that tools and plugins behind the scenes actually follow those choices.
That’s where the WP Consent API shines. It makes life easier by:
Giving all plugins access to the same consent information
Letting you react instantly when a user changes their settings
Allowing you to define your own consent types (like tracking, personalization, etc.)
Saving you from having to write custom consent logic for every tool you use
Basically, it keeps everything consistent, so you don’t end up with one plugin following consent rules and another one ignoring them.
How CookieScript Works With WP Consent API
The CookieScript plugin now includes optional support for the WP Consent API. That means whenever a user interacts with the CookieScript banner—whether they accept everything, reject it all, or choose specific categories—those preferences are automatically sent to the WP Consent API.
In plain English, CookieScript is now in charge of the consent state in WordPress.
So if you’re using other plugins that depend on the WP Consent API, they’ll instantly pick up the user’s choices from CookieScript and act accordingly.
Just make sure the WP Consent API plugin is installed and turned on for the integration to work.
How to Set Up WP Consent API with CookieScript in WordPress
If you’d like to take advantage of CookieScript’s integration with the WP Consent API, follow these simple steps to get everything working smoothly.
Step 1: Install the WP Consent API Plugin
Log into your WordPress Admin Dashboard
Go to Plugins > Add New
In the search bar, type: “WP Consent API”
Find the plugin (usually published by Allejo) and click Install Now
Once installed, click Activate
You can also visit the official WP Consent API website for more information or direct download.
CookieScript will automatically sync user preferences with the WP Consent API whenever someone interacts with the consent banner.
Code Examples: Using WP Consent API
The following examples show how you can use WP Consent API to read, respond to, and register consent on your WordPress site.
1. Checking Consent for a Category
You can check whether a user has given consent to a specific category like marketing:
2. Listening for Consent Changes
You can respond to changes in consent:
3. Registering a New Consent Category
If your plugin or theme needs a custom category (e.g., ads), register it with:
4. Loading Scripts Based on Consent
A common use case is to load external services only if the user has consented:
Method 2: Installing Cookie-Script for WordPress by editing theme files.
Go to your Cookie-Script.com account > Settings > Install:
Press the Wordpress tab and copy your CookieScript code.
Log in to your WordPress Admin Dashboard.
Hover Appearance and click on Theme Editor.
Find and click on the header.php template file.
Paste copied Cookie-Script snippet at the beginning of the <body> tag.
Click the Update File button.
CookieScript is installed on WordPress now and should be ready for use.
Note: CookieScript does not block third-party cookies by default. You need to configure your banner settings
first, choosing one of the methods. Read the guide on how to block third-party cookies.
Note: If the banner doesn’t appear after the implementation, check if you don’t use any Cache plugin or extension, which prevents the banner from popping-up.
Common problems:
1. If you have issues with the Cart, add the following cookies to CookieScript cookie declaration as strictly necessary cookies:
2. To fix the "Invalid script detected" issue, ensure you select WordPress in the Banner Settings under Install section. Verify that you copied the generated code specifically for WordPress and use it in Plugin.
Did this answer your question?