clickio

Adv loaded before users'consent - Outbrain

Apr 21st, 2021 (edited)
541
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 1) First of all, you need to add the following code to the head of the page before any other ad serving code (including Clickio Consent Tool code).
  2.  
  3. <script type="text/javascript">
  4. var consentCallbackQueue=function(e,o){var t=!1,n=!1;let a=[],g=!1,l=!1,s=function(){g=!0,a.map(function(e,o){void 0!==e&&(e(t,n),a[o]=void 0)})};return document.documentElement.addEventListener("clickioConsentEvent",function(o){var a;a=o.detail.state,l=!0,null===a?(t=!0,n=!0,s()):-1===a||(0===a?(t=!1,n=!1,s()):1===a&&(t=!!e.__lxG__consent__.getGoogleConsentMode(),n=!!e.__lxG__consent__.getPurposeOneAllowed(),s()))},!1),setTimeout(function(){l||document.documentElement.dispatchEvent(new CustomEvent("clickioConsentEvent",{detail:{state:0}}))},5e3),{push:function(e){g?e(t,n):a.push(e)}}}(window);
  5. </script>
  6.  
  7.  
  8. 2) Your current Outbrain tag looks like this:
  9.  
  10. <div class="OUTBRAIN" data-src="DROP_PERMALINK_HERE" data-widget-id="AR_1"></div>
  11. <script type="text/javascript">
  12. document.querySelector(".OUTBRAIN").setAttribute('data-src', window.location.protocol + '//' + window.location.host + window.location.pathname)
  13. </script>
  14. <script type="text/javascript" async="async" src="//widgets.outbrain.com/outbrain.js"></script>
  15.  
  16.  
  17. You need to replace current Outbrain tag by the following script:
  18.  
  19. <div class="OUTBRAIN" data-src="DROP_PERMALINK_HERE" data-widget-id="AR_1"></div>
  20. <script type="text/javascript">
  21. (function(d,w){
  22.     consentCallbackQueue.push(function () {
  23.         d.querySelector(".OUTBRAIN").setAttribute('data-src', w.location.protocol + '//' + w.location.host + w.location.pathname)
  24.         let u = "https://widgets.outbrain.com/outbrain.js";
  25.         if(!d.querySelector("script[src=\"" + u + "\"]")) {
  26.             let s = d.createElement("script");
  27.             s.src = u;
  28.             s.async = "async";
  29.             d.querySelector("head").appendChild(s);
  30.         }
  31.     });
  32. })(document, window);
  33. </script>
  34.  
  35.  
Add Comment
Please, Sign In to add comment