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 it as ‘no’.
On inserting the above code snippet to the function.php file, the script blocker interface will be as shown below:
Two new additional script blockers namely Google Translator and Recaptcha are appended along with the existing service script blockers.
Refer How to Automatically Block Cookies Using the GDPR Cookie Consent Plugin to know more on it.
Jean
December 6, 2023
Hi !
How can I add a script for an embed Dailymotion video ?
Would be really helpful !
Thx
Hema
December 20, 2023
Hello Jean
Thanks for reaching out. It seems you need custom code to enbed videos. Kindly contact customer support for further assistance.
Jean
November 17, 2023
Hi,
I tried to block leaflet third party script.
What should be the ID for leaflet for my custom script ??
Thx
Hema
December 20, 2023
Hello Jean,
Thanks for reaching out. It seems you need custom code to block the script. Kindly contact customer support for further assistance.
Richa
February 15, 2023
I added thrid party script throug function file. Is this paid version will work on custom code as well?
Mark
March 6, 2023
Hi Richa,
Greetings from Webtoffee!
The custom script blocker should be able to block the script that you added. You can try our custom script blocker snippet, and if you feel you need further assistance with it, reach our technical support through the support page.
compras-nunsys
December 28, 2022
In my script blocker options not appear rows from row 17. It ends at row 16 and I need to configure Google Adsense and Hubspot Analytics options. How can I add these rows?
Mark
January 5, 2023
Hi,
Greetings from Webtoffee!
It seems you require some technical assistance. Please contact our support for further assistance.
Mael
December 5, 2021
Is the Blocking Custom Scripts functionality available only for the paid version?
Mark
December 6, 2021
Hi Mael,
Greetings from Webtoffee!
Custom script blocker functionality via filter is available only in the premium version of the plugin. You can block scripts in free version too if you add the script via the category edit pages directly.
Enrico
December 29, 2021
Hi Mark,
I tried to block scripts in free version by adding the following script: enableVISITOR_INFO1_LIVE(); via the category edit page but it didn’t work. The embed Youtube video is in the body of the page. What am I doing wrong?
Mark
February 2, 2022
Hi Enrico,
With the free version plugin, you will need to add the entire embed script via the plugin category itself instead of adding via theme. While this may be efficient for scripts like analytics, it may not be applicable for youtube embed as it has to be placed in a specific position in the page. As such you may need to use our pro version plugin, which is capable of directly blocking the youtube scripts even if added directly in theme or via a page.
Alexander Gerard
November 26, 2021
Hey, how can i block mailchimp for woocommerce?
i found this cookie by cookie-scanner and they categorized it on not necessary.
In Chrome unter Cookies, “mailchimp_landing_site” isnt disabled if i reload the page?
So i must write a custom script blocker, or?
Can you write me the code for the function.php?
Mark
November 29, 2021
Hi Alexander,
We can surely help you with the request. Since this is more of a custom requirement, please submit a ticket here with site details, the page URL where the script runs and your order number.
tomislav
September 10, 2021
How to block Vimeo live embed? I tried
function scripts_list() {
$scripts = array(
array(
‘id’ => ‘vimeoplayer’,
‘label’ => ‘vimeoplayer’,
‘key’ => array(‘f.vimeocdn.com/p/3.40.0/js/player.js’),
‘category’ => ‘functional’,
‘status’ => ‘yes’
),
array(
‘id’ => ‘vimeoplaylist’,
‘label’ => ‘vimeoplaylist’,
‘key’ => array(‘f.vimeocdn.com/js_opt/_bundles/embed_playlist.bundle.min.js’),
‘category’ => ‘functional’,
‘status’ => ‘yes’
),
array(
‘id’ => ‘vimeomanager’,
‘label’ => ‘vimeomanager’,
‘key’ => array(‘f.vimeocdn.com/js_opt/global/player_manager.min.js’),
‘category’ => ‘functional’,
‘status’ => ‘yes’
),
array(
‘id’ => ‘vimeomux’,
‘label’ => ‘vimeomux’,
‘key’ => array(‘f.vimeocdn.com/p/external/mux.js’),
‘category’ => ‘functional’,
‘status’ => ‘yes’
),
);
return $scripts;
}
add_filter(‘cli_extend_script_blocker’, ‘scripts_list’, 10, 1);
Mark
September 10, 2021
Hi,
Vimeo embed script is supported by the script blocker by default and will be among the default ones listed under the Script Blocker page. Please try enabling it.
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.