Pausing Google AdSense and Ad Manager tags

If you intend to use non-Clickio Google-based ads codes on the page with the Clickio Consent Tool, those may not be paused because of different reasons, to help you with that, you can use one of the codes provided here to make it work. Just add the chosen code to the head of the page before any other ad serving code (including Clickio Consent Tool code).

For more information, technical explanations, and custom integrations example please refer to this article.

AdSense
<script type="text/javascript">
  var adsbygoogle=window.adsbygoogle||[];
  adsbygoogle.pauseAdRequests=1;
  
  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);
   
  consentCallbackQueue.push(function(e,o){e&&(adsbygoogle.pauseAdRequests=0)});
</script>
Ad Manager
<script type="text/javascript">
  var googletag=googletag||{};
  googletag.cmd=googletag.cmd||[];
  googletag.cmd.unshift(function(){window.googletag.pubads().disableInitialLoad()});

  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);
  
  function displayAndRefreshSlotById(e){consentCallbackQueue.push(function(o,t){o&&googletag.cmd.push(function(){googletag.pubads().isInitialLoadDisabled()?googletag.pubads().getSlots().forEach(function(o){o.getSlotElementId()==e&&(googletag.display(e),googletag.pubads().refresh([o]))}):googletag.display(e)})})}
</script>

Mind that for the correct functioning of the code (i.e. ad slots refresh after consent state is determined) you should also replace the current Ad Manager display codes:

<script type="text/javascript">
googletag.cmd.push(function(){
	googletag.display('div-id-1');
});
</script>

with the provided wrapper code:

<script type="text/javascript">
displayAndRefreshSlotById('div-id-1');
</script>

This code will not call googletag.display before user consent, once it is received, it will push the command to the googletag queue and also call refresh for the slot, if isInitialLoadDisabled is true. If any tags are not replaced with the provided wrapper code (i.e. 3rd party codes), you should manually call refresh for the slot using the consentCallbackQueue.

AdSense & Ad Manager simultaneously

<script type="text/javascript">
  var googletag=googletag||{};
  googletag.cmd=googletag.cmd||[];
  googletag.cmd.unshift(function(){window.googletag.pubads().disableInitialLoad()});
  
  var adsbygoogle=window.adsbygoogle||[];
  adsbygoogle.pauseAdRequests=1;
  
  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);
  
  function displayAndRefreshSlotById(e){consentCallbackQueue.push(function(o,t){o&&googletag.cmd.push(function(){googletag.pubads().isInitialLoadDisabled()?googletag.pubads().getSlots().forEach(function(o){o.getSlotElementId()==e&&(googletag.display(e),googletag.pubads().refresh([o]))}):googletag.display(e)})})}
  
  consentCallbackQueue.push(function(e,o){e&&(adsbygoogle.pauseAdRequests=0)});
</script>

You should also replace Ad Manager display codes with the wrapper code as explained in the Ad Manager section.