โ–ถ๏ธ 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

Before Marketing consent

  • 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

If the visitor later withdraws Marketing consent

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