> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://help.hoppyapps.com/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# ▶️ 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