This page demonstrates how to conditionally load an iframe (YouTube video) based on Marketing consent.

Update Cookie Preferences

Conditional Section

iFrame Example when MARKETING is accepted
<!-- Iframe appears only when Marketing is ACCEPT --> <div class="conditional-content" id="iframe-content" style="display:none;"> <h3>Embedded Content</h3> <iframe width="560" height="315" src="https://www.youtube.com/embed/yoE9-tNvhRs?si=zu_aHce1AhD9h8C1" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe> </div> <div class="consent-required-message" id="iframe-message"> <p>Enable Marketing/Targeted Advertising in your <a href="javascript:void(0)" onclick="Osano.cm.showDrawer()">Cookie Preferences</a> to view the embed.</p> </div> <script> function updateIframe(consent) { if (!consent) return; var content = document.getElementById('iframe-content'); var message = document.getElementById('iframe-message'); if (consent.MARKETING === 'ACCEPT') { content.style.display = 'block'; message.style.display = 'none'; } else { content.style.display = 'none'; message.style.display = 'block'; } } document.addEventListener('DOMContentLoaded', function() { if (typeof Osano !== 'undefined' && Osano.cm) { Osano.cm.addEventListener('osano-cm-initialized', function(consent) { updateIframe(consent); }); Osano.cm.addEventListener('osano-cm-consent-saved', function(consent) { updateIframe(consent); }); } }); </script>