Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • ThomasBrunbjerg 90 posts 182 karma points
    Oct 28, 2022 @ 08:04
    ThomasBrunbjerg
    0

    Blocked embedded YouTube videos unless Marketing cookies have been accepted in Umbraco

    I need to block embedded YouTube videos unless Marketing cookies have been accepted by the user. Our site uses Umbraco as CMS, which means most, though not all, videos are being embedded through the Umbraco backoffice.

    I've been following this guide: https://support.cookiebot.com/hc/en-us/articles/360003790854-Iframe-cookie-consent-with-YouTube-example

    This works fine for already implemented iframes in the code, but I'm not sure how to make this work for Umbraco video embeds.

    I found a question similar to mine here: https://our.umbraco.com/forum/using-umbraco-and-getting-started/105092-gridlayout-embed-with-cookiebot

    In my default embed view at Views/Partials/Grid/Embed.cshtml, i now have the following code:

    @model dynamic
    @using Umbraco.Web.Templates
    @{
        string embedValue = Convert.ToString(Model.value);
        embedValue = embedValue.DetectIsJson() ? Model.value.preview : Model.value;
        embedValue = embedValue.Replace(" src=", "data-cookieconsent=\"marketing\" data-src=");
    }
    
    <div class="video-wrapper">
        @Html.Raw(Model.value)
    </div>
    

    My question is how this would work for all existing embeds on the site? What would be the best way of testing this?

Please Sign in or register to post replies

Write your reply to:

Draft