How to block third-party codes & cookies if no consent is given?
Automatic vs. Manual Blocking
ConsentManager offers manual and automatic Blocking of Codes and Cookies. Despite that automatic blocking is easier to install, for compliance reasons we recommend to use manual blocking!
Here is a comparison of the two blocking methods:
Automatic Blocking
You can read more about Automatic Blocking of Codes and Cookies here. |
Manual Blocking
We recommend using manual blocking in order to avoid compliance issues! |
Manual Blocking of Codes and Cookies
The CMP can postpone the load of ads on your website until consent is given. In order to enable this feature you need to change existing creative codes on your website.
Please note that blocking / postponed loading only works with asynchronous script codes and Iframe codes and not with synchronous script codes.
Iframe-Codes
If you want to postpone an iframe code, please follow these steps:
- Change the
src="…"
attribute of the iframe todata-cmp-src="…"
- Add a new
src="about:blank"
attribute to the iframe - If a
class="…"
exists, addcmplazyload
to the value. If class does not exist, add the attribute including the valueclass="cmplazyload"
- Add a new attribut
data-cmp-vendor="x"
and/ordata-cmp-purpose="x"
in order to fire the code only if consent for this vendor and purpose is given. See info below.
Example code before change:
<iframe width="300" height="250" noresize="noresize" scrolling="no"
frameborder="0" marginheight="0" marginwidth="0"
src="http://adserver.de/?x=1&y=2"
ALLOWTRANSPARENCY="true"></iframe>
Example code after change:
<iframe width="300" height="250" noresize="noresize" scrolling="no"
frameborder="0" marginheight="0" marginwidth="0"
class="cmplazyload"
src="about:blank"
data-cmp-vendor="123"
data-cmp-src="http://adserver.de/?x=1&y=2"
ALLOWTRANSPARENCY="true"></iframe>
asynchronous Script-Codes
If you want to postpone the load of an async. Script code, please follow these steps:
- If a
src="..."
exists, change thesrc="…"
attribute of the script todata-cmp-src="…"
- If a
type="..."
exists, change its value totext/plain
, otherwise add the attribute with this valuetype="text/plain"
. - If a
class="…"
exists, addcmplazyload
to the value. If class does not exist, add the attribute including the valueclass="cmplazyload"
- Add a new attribut
data-cmp-vendor="x"
and/ordata-cmp-purpose="x"
in order to fire the code only if consent for this vendor and purpose is given. See info below.
Example code 1 before change:
<script async
src="https://adserver.de/banner.php" type="text/javascript"></script>
Example code 1 after change:
<script async class="cmplazyload" data-cmp-vendor="123"
data-cmp-src="https://adserver.de/banner.php" type="text/plain"></script>
Example code 2 before change:
<script type="text/javascript">
console.log("do something here");
</script>
Example code 2 after change:
<script type="text/plain" class="cmplazyload" data-cmp-vendor="123">
console.log("do something here");
</script>
Additional attributes
The following additional attributes can be added to script/iframe codes in order to further align the delivery to certain consent results:
Attribut |
Description |
|
if present, CMP will hide the iframe if consent is not given and unhide the iframe if consent is given |
|
CMP will only activate this script/iframe if consent for vendor |
|
CMP will only activate this script/iframe if consent for purpose |
|
CMP will display a preview (see dynamic content blocking) element in this position. |
|
Tells the CMP to unblock all other elements with class xxx once this element gets unblocked. |
|
The CMP will not use automatic blocking with this element. |
|
The CMP will not use automatic blocking with this element and all elements that are created by this element. |
Note: If data-cmp-vendor="..."
and data-cmp-purpose="..."
are not present, the system will check if at least 1 purpose was accepted. If that is the case, the code will be activated.
You can find the IDs of all purposes in menu Purposes:
You can find the IDs of all vendors in menu Vendors/Whitelist: