How to add custom script blocker in WordPress
Script Blocking is of vital importance when it comes to GDPR Cookie compliance. The premium version of the GDPR Cookie Consent plugin has the capability to automatically block the active scripts that inject cookies on the website until the users give their explicit consent. The inbuilt script blocker in this plugin is capable of blocking cookies from the following third-party scripts:

Blocking Custom Scripts
Apart from the above-listed pre-defined scripts, the GDPR Cookie consent plugin also allows adding a custom script blocker extension whereby the user can explicitly block scripts of their choice.
To achieve this simply add the below code snippet to the active child theme functions.php.
The above code snippet inserts two new script blockers from Google Translator and Recaptcha. Likewise, you can insert scripts accordingly by entering appropriate values for the array fields id, label, key, category, and status.
- id: Key in the name of the script.
- label: Enter an appropriate label name for the script blocker that will appear in the interface.
- key: Specify any number of unique strings separated with commas that can be used to identify your script(an array of strings).
- category: The plugin maintains necessary and non-necessary as two default categories. Assign the category slug of an existing category for the script. If such a category does not exist then create a new cookie category and assign its slug.
Note: Ensure that the correct slug (lower case) of the corresponding category is placed in the code snippet. - status: Set the status as ‘yes’ to make it active by default else set as ‘no’.
On inserting the above code snippet to the function.php file, the script blocker interface will be as shown below:

Comments (8)
Charles
February 3, 2021
When I follow the example above, the Script Blocker I add does not have a toggle for enable/disable – it simply shows “Enable” as text in the UI if I use ‘yes’ as the status and “Disabled” if I use ‘no’ or omit status. Similarly, the categories are also presented as plain text and not as select controls as shown in the screenshot above. That means neither of those values is editable without updating functions.php as there’s no way to update them in the admin interface. Is there another value I need to pass to change those behaviors?
Mark
February 9, 2021
We understand your concern. Custom script blocker codes added via the filters can be modified only by editing the code itself.
Ashish
November 15, 2020
Hi, I tried to add the custom script for adsense but it didn’t work. The scripts are not blocked as the advertise is being displayed before the user consent. Can you please provide more specific details for adding google adsense scripts.
Mark
November 16, 2020
Hi Ashish,
Please contact support with your site URL and script of adsense that you are using.
luis
November 11, 2020
thast not works for me. action in fuction added and not appear in /wp-admin/edit.php?post_type=cookielawinfo&page=cli-script-settings
Andres
May 9, 2020
Will this cover CCPA? I assume that it does for GPDR as the title says what happens if there is a change that will diverge the 2 regulations?
Mark
May 14, 2020
Currently, we do not have full CCPA compatibility. It will be added in coming releases.
Mark
August 7, 2020
From Version 2.3.0 onwards, we have added CCPA compatibility functionalities to the plugin.