I am looking for a possibility to block YouTube-iframes (and similar embeds) from loading/setting cookies until the user clicks or allows it deliberately. Certainly I would prefer using a native EE functionality, but I also would use an commercial addon.

Thanks for any hints!


It's not too bad!

In the control panel Settings > Consent requests create a new request called "video_consent" or similar, this name is used in the consent form, example below.

Now add the following code snippet to wherever you output your video:

    <!-- check if the consent has NOT been granted -->
    {if ! consent:has_responded:ee:video_consent}
        <!-- show the consent form-->
        {exp:consent:form consent='ee:video_consent' form_id='cookieConsentForm' form_class='consent-form'}
            <!-- get the consent input as a hidden field -->
                <input type="hidden" name="{consent_short_name}" value="y">
            <button type="submit">Allow video</button>
    <!-- if consent has been granted show video code-->
        Your video code

On submission of the form the page will reload and show your video code.

Not tested but give it a try!

  • Thanks! But when I have videos in my posts I don't want to add code into the posts. I would rather prefer to block them globally. – BNetz Nov 27 '20 at 5:33

You could use the Consent module for this. By default you'd prevent embed videos from loading and offer a consent form with whatever options you need. If consent is granted you'd probably want to reload the current page, but this time with the embed code present.

  • Yes - but implementing this in the way you describe it does require a high level of technical expertise, as far as I see - implementing some javascript-acceptance-window which is communicating with the consent-module. Or is it easier than I think? – BNetz Nov 25 '20 at 16:34
  • It depends how you're managing your content, if you have structured content using EE's Fluid or Grid fields then you can easily segregate video content as in my example. However, if you put all you content into one field you'll probably have to use a different solution with Javascript. – Bluedreamer Nov 28 '20 at 14:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.