Support » Plugin: Civic Cookie Control 8 » Embedded YouTube videos

  • Resolved mtrehearn

    (@mtrehearn)


    Hi,

    I have embedded iframe YouTube videos on my site and although I use the YouTube enhanced privacy / no cookie solution to remove most tracking cookies it still sets some cookies when the user plays the video for preferences etc.

    Is there a way to remove the YouTube videos altogether and instead place a “you must consent to the YouTube cookies” type message then once the user turns on consents to those cookies then reveal the iframe and therefore video (similar to the process for analytics)?

    Thanks in advance.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Tasos Fel

    (@tasoscivicuk)

    Hi,

    You can create the youtube iframes dynamically inside the onAccept callback. That way the iframes will not be on the page until the user consents. So the onAccept could be like this:

    onAccept: function() {
    
        var iframe = document.createElement("iframe");
        iframe.src = <youtube-url>;
        iframe.id = "youtube-iframe";
        var youtubeHolder = document.getElementById("yt-holder");
        youtubeHolder.appendChild(iframe);
    
    }

    You should use a similar snippet for all videos on the page. Similarly, inside the onRevoke you could remove all of these iframes, using the removeChild() method:

    onRevoke: function() {
    
      var frame = document.getElementById("youtube-iframe");
      frame.parentNode.removeChild(frame);
    
    }

    Hi,

    Thank you for your help.

    Appreciate this.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.