Articles on: Cookie Consent
This article is also available in:

▢️ How to Block YouTube Embeds Until Consent

Embedded YouTube videos can set tracking cookies as soon as a page loads. The YouTube Embed integration in GDPR EU Cookie Banner replaces embedded videos with a placeholder until the visitor accepts Marketing cookies, then restores them.



⚠️ Before You Begin


Make sure:


  • GDPR EU Cookie Banner is installed, the App Embed is enabled, and your banner is published
  • Your videos are embedded as YouTube iframes (the standard "Embed" option)



πŸ› οΈ Step 1 β€” Open the Integration


➑️ Open GDPR EU Cookie Banner


➑️ Click Integrations in the left menu


➑️ Open the YouTube Embed card
(Block YouTube iframes to prevent tracking cookies until consent is given.)



βš™οΈ Step 2 β€” Enable It


➑️ Click Enable so the status reads YouTube Embed is currently Enabled


➑️ Click Save in the save bar


The page explains the behavior: When enabled, YouTube embedded videos will be blocked until visitors give marketing consent. A placeholder will be shown in place of the video.



πŸ”„ How It Works



  • YouTube iframes on the page have their source removed and are hidden
  • A dark placeholder box is shown in the same space, with the text "This video is blocked until you accept marketing cookies."


After the visitor accepts Marketing


  • The original video is restored and plays normally
  • The placeholder is removed



The videos are blocked again and placeholders return.


Videos added after the page loads


The banner keeps watching the page, so videos added later by your theme or apps are also blocked until consent is given.



πŸ§ͺ Step 3 β€” Test the Integration


You can also open View guide under Step 2: Test if integration with YouTube Embed works successfully.


Test with Decline


➑️ Open a page that contains a YouTube video in an Incognito or Private window


➑️ Open the browser console (press F12)


➑️ Decline marketing cookies


➑️ Type document.querySelectorAll('.hoppy-youtube-placeholder').length and press Enter


Expected result: a number greater than 0, and the page shows the placeholder instead of the video.


Test with Accept


➑️ Open a fresh Incognito or Private window and click the accept button in the banner (default text: Accept)


➑️ Run the same command


Expected result: 0, and the video plays.



πŸ› οΈ Troubleshooting


A video is not blocked


  • Check that the status is Enabled and you clicked Save
  • The integration blocks iframes whose address contains youtube.com/embed/ or youtube-nocookie.com/embed/. Videos loaded another way, for example through a custom player, are not covered
  • Visitors outside the regions you selected under Banner settings β†’ Region are not managed by the banner, so their videos are not blocked


The placeholder stays after accepting


  • Confirm the visitor accepted Marketing, not only Analytics
  • Refresh the page and test again in a new Incognito window


The placeholder text is in English


The placeholder text is fixed and is not translated through the Translation page.


Video looks smaller or larger


The placeholder uses the size set on the video embed, or 100% width and 360px height when none is set.



⚠️ Important Notes


  • Only the Marketing category controls this integration
  • With the Decline only banner type, all cookies are allowed by default, so videos are not blocked unless the visitor declines
  • The banner script loads with the page, so a video can briefly appear before it is replaced on slower connections
  • Always check your own pages after enabling, especially product pages and landing pages that use videos



πŸŽ‰ Final Result


βœ… YouTube videos are blocked until Marketing consent is given


βœ… Visitors see a clear placeholder instead of an empty gap


βœ… Videos play normally after consent

Updated on: 27/11/2026

Was this article helpful?

Share your feedback

Cancel

Thank you!