βΆοΈ 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/oryoutube-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
Thank you!