Ajustar el código del esbozo

El código stub (la parte del código que se integra en tu sitio web) incluye automáticamente compatibilidad con IAB TCF v1, IAB TCF v2 e IAB USP. En algunos casos, la compatibilidad con IAB TCF puede causar problemas. Para evitarlos, puedes reformatear tu código stub de la siguiente manera:

<script>window.gdprAppliesGlobally=false; //set this to true or false depending on your needs
//no changes below this line
  window.cmp_id=123456;window.cmp_params="";
  window.cmp_host="delivery.consentmanager.net";window.cmp_cdn="cdn.consentmanager.net";function cmp_getlang(j){if(typeof(j)!="boolean"){j=true}if(j&&typeof(cmp_getlang.usedlang)=="string"&&cmp_getlang.usedlang!==""){return cmp_getlang.usedlang}var g=["DE","EN","FR","IT","NO","DA","FI","ES","PT","RO","BG","ET","EL","GA","HR","LV","LT","MT","NL","PL","SV","SK","SL","CS","HU","RU","SR","ZH"];var c=[];var f=location.hash;var e=location.search;var a="languages" in navigator?navigator.languages:[];if(f.indexOf("cmplang=")!=-1){c.push(f.substr(f.indexOf("cmplang=")+8,2))}else{if(e.indexOf("cmplang=")!=-1){c.push(e.substr(e.indexOf("cmplang=")+8,2))}else{if("cmp_setlang" in window&&window.cmp_setlang!=""){c.push(window.cmp_setlang.toUpperCase())}else{if(a.length>0){for(var d=0;d<a.length;d++){c.push(a[d])}}}}}if("language" in navigator){c.push(navigator.language)}if("userLanguage" in navigator){c.push(navigator.userLanguage)}var h="";for(var d=0;d<c.length;d++){var b=c[d].toUpperCase();if(b.indexOf("-")!=-1){b=b.substr(0,2)}if(g.indexOf(b)!=-1){h=b;break}}if(h==""){h="EN"}h=h.toUpperCase();return h}(function(){var a="";var c="_en";if("cmp_getlang" in window){a=window.cmp_getlang().toLowerCase();c="_"+a}var b=document.createElement("script");b.src="https://"+window.cmp_host+"/delivery/cmp.php?id="+window.cmp_id+"&h="+encodeURIComponent(location.href)+"&"+window.cmp_params+(document.cookie.length>0?"&__cmpfcc=1":"")+"&l="+a+"&o="+(new Date()).getTime();b.type="text/javascript";b.setAttribute("data-cmp-ab",1);b.async=true;if(document.body){document.body.appendChild(b)}else{if(document.currentScript){document.currentScript.parentElement.appendChild(b)}else{document.write(b.outerHTML)}}var b=document.createElement("script");b.src="https://"+window.cmp_cdn+"/delivery/cmp"+c+".min.js";b.type="text/javascript";b.setAttribute("data-cmp-ab",1);b.async=true;if(document.body){document.body.appendChild(b)}else{if(document.currentScript)
  {document.currentScript.parentElement.appendChild(b)}else{document.write(b.outerHTML)}}window.cmp_addFrame=function(e){if(!window.frames[e]){if(document.body){var d=document.createElement("iframe");d.style.cssText="display:none";d.name=e;document.body.appendChild(d)}else{window.setTimeout('window.cmp_addFrame("'+e+'")',10)}}};window.cmp_rc=function(j){var d=document.cookie;var g="";var f=0;while(d!=""&&f<100){f++;while(d.substr(0,1)==" "){d=d.substr(1,d.length)}var h=d.substring(0,d.indexOf("="));if(d.indexOf(";")!=-1){var e=d.substring(d.indexOf("=")+1,d.indexOf(";"))}else{var e=d.substr(d.indexOf("=")+1,d.length)}if(j==h){g=e}i=d.indexOf(";")+1;if(i==0){i=d.length}d=d.substring(i,d.length)}return(g)};window.cmp_stub=function(){var d=arguments;__cmp.a=__cmp.a||[];if(!d.length){return __cmp.a}else{if(d[0]==="ping"){if(d[1]===2){d[2]({gdprApplies:gdprAppliesGlobally,cmpLoaded:false,cmpStatus:"stub",displayStatus:"hidden",apiVersion:"2.0",cmpId:31},true)}else{d[2]({gdprAppliesGlobally:gdprAppliesGlobally,cmpLoaded:false},true)}}else{if(d[0]==="getUSPData"){d[2]({version:1,uspString:window.cmp_rc("")},true)}else{if(d[0]==="getTCData"){__cmp.a.push([].slice.apply(d))}else{if(d.length==4&&d[3]===false){d[2]({},false)}else{__cmp.a.push([].slice.apply(d))}}}}}};window.cmp_msghandler=function(h){var d=typeof h.data==="string";try{var g=d?JSON.parse(h.data):h.data}catch(j){var g=null}if(typeof(g)==="object"&&g!==null&&"__cmpCall" in g){var f=g.__cmpCall;window.__cmp(f.command,f.parameter,function(l,k){var e={__cmpReturn:{returnValue:l,success:k,callId:f.callId}};h.source.postMessage(d?JSON.stringify(e):e,"*")})}if(typeof(g)==="object"&&g!==null&&"__uspapiCall" in g){var f=g.__uspapiCall;window.__uspapi(f.command,f.version,function(l,k){var e={__uspapiReturn:{returnValue:l,success:k,callId:f.callId}};h.source.postMessage(d?JSON.stringify(e):e,"*")})}if(typeof(g)==="object"&&g!==null&&"__tcfapiCall" in g){var f=g.__tcfapiCall;window.__tcfapi(f.command,f.version,function(l,k){var e={__tcfapiReturn:{returnValue:l,success:k,callId:f.callId}};h.source.postMessage(d?JSON.stringify(e):e,"*")},f.parameter)}};window.cmp_setStub=function(d){if(!(d in window)||(typeof(window[d])!=="function"&&typeof(window[d])!=="object"&&(typeof(window[d])==="undefined"||window[d]!==null))){window[d]=window.cmp_stub;window[d].msgHandler=window.cmp_msghandler;if(window.addEventListener){window.addEventListener("message",window.cmp_msghandler,false)}else{window.attachEvent("onmessage",window.cmp_msghandler)}}};
//no changes above this line
window.cmp_addFrame("__cmpLocator"); //remove this line to remove IAB TCF v1 support
window.cmp_addFrame("__uspapiLocator"); //remove this line to remove IAB USP support
window.cmp_addFrame("__tcfapiLocator"); //remove this line to remove IAB TCF v2 support
window.cmp_setStub("__cmp"); //leave this line in the code
window.cmp_setStub("__tcfapi"); //remove this line to remove IAB TCF v2 support
window.cmp_setStub("__uspapi"); //remove this line to remove IAB USP support
//no changes below this line
})();</script>

Ten en cuenta que el ejemplo anterior es una versión formateada; es posible que tu código no esté formateado (sin saltos de línea ni comentarios).

  1. Cambia la línea window.gdprAppliesGlobally a true si quieres utilizar el TCF a nivel global. Si quieres utilizar otras legislaciones fuera de Europa, quizá te interese establecer el valor en false.
  2. Elimina la línea que incluye la palabra __cmpLocator para eliminar la compatibilidad con TCF v1
  3. Elimina las líneas que incluyan las palabras __tcfapiLocator y __tcfapi para eliminar la compatibilidad con TCF v2
  4. Elimina las líneas que incluyan las palabras __uspapiLocator y __uspapi para eliminar la compatibilidad con IAB USP

We do our best to keep this purely informative documentation up to date. However, if you notice that any of these guides need a little touch-up, let us know!