Block embedded content (YouTube, Google Maps, Twitter) until user consent. Free GDPR-compliant solution for third-party embeds.
Free forever. GDPR compliant. Works with all major embeds.
Configure your embed consent tool below. Copy the generated code and add it to your website.
This content is blocked until you accept cookies
<!-- Embed Consent Tool by TermsBox - https://termsbox.com/embed-consent -->
<script>
(function() {
'use strict';
var TERMSBOX_EMBED_CONFIG = {
blockedDomains: ["youtube.com","youtu.be","vimeo.com","google.com/maps","maps.google.com"],
placeholderText: "This content is blocked until you accept cookies",
buttonText: "Accept & Load Content",
theme: "light",
rememberConsent: true,
consentDays: 30,
storageKey: 'termsbox_embed_consent'
};
function hasConsent() {
if (!TERMSBOX_EMBED_CONFIG.rememberConsent) return false;
try {
var consent = localStorage.getItem(TERMSBOX_EMBED_CONFIG.storageKey);
if (!consent) return false;
var data = JSON.parse(consent);
return data.granted && data.expires > Date.now();
} catch (e) {
return false;
}
}
function saveConsent() {
if (!TERMSBOX_EMBED_CONFIG.rememberConsent) return;
try {
var expires = Date.now() + (TERMSBOX_EMBED_CONFIG.consentDays * 24 * 60 * 60 * 1000);
localStorage.setItem(TERMSBOX_EMBED_CONFIG.storageKey, JSON.stringify({
granted: true,
expires: expires
}));
} catch (e) {
// localStorage not available
}
}
function shouldBlock(src) {
if (!src) return false;
var srcLower = src.toLowerCase();
return TERMSBOX_EMBED_CONFIG.blockedDomains.some(function(domain) {
return srcLower.indexOf(domain) !== -1;
});
}
function createPlaceholder(iframe) {
var placeholder = document.createElement('div');
placeholder.className = 'termsbox-embed-placeholder';
placeholder.style.cssText = 'display:flex;flex-direction:column;align-items:center;justify-content:center;' +
'padding:40px 20px;text-align:center;border-radius:8px;min-height:200px;' +
(TERMSBOX_EMBED_CONFIG.theme === 'dark'
? 'background:#1f2937;color:#f3f4f6;border:1px solid #374151;'
: 'background:#f3f4f6;color:#1f2937;border:1px solid #e5e7eb;');
var icon = document.createElement('div');
icon.innerHTML = '<svg width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="11" width="18" height="11" rx="2" ry="2"/><path d="m7 11V7a5 5 0 0 1 10 0v4"/></svg>';
icon.style.cssText = 'margin-bottom:16px;opacity:0.6;';
var text = document.createElement('p');
text.textContent = TERMSBOX_EMBED_CONFIG.placeholderText;
text.style.cssText = 'margin:0 0 16px 0;font-size:14px;max-width:300px;';
var button = document.createElement('button');
button.textContent = TERMSBOX_EMBED_CONFIG.buttonText;
button.style.cssText = 'padding:10px 20px;border-radius:6px;cursor:pointer;font-weight:500;font-size:14px;' +
'border:none;transition:opacity 0.2s;' +
(TERMSBOX_EMBED_CONFIG.theme === 'dark'
? 'background:#3b82f6;color:#ffffff;'
: 'background:#2563eb;color:#ffffff;');
button.onmouseover = function() { this.style.opacity = '0.9'; };
button.onmouseout = function() { this.style.opacity = '1'; };
button.onclick = function() {
saveConsent();
loadAllEmbeds();
};
placeholder.appendChild(icon);
placeholder.appendChild(text);
placeholder.appendChild(button);
return placeholder;
}
function loadAllEmbeds() {
var placeholders = document.querySelectorAll('.termsbox-embed-placeholder');
placeholders.forEach(function(placeholder) {
var iframe = placeholder.termsboxOriginalIframe;
if (iframe && placeholder.parentNode) {
placeholder.parentNode.replaceChild(iframe, placeholder);
}
});
}
function processIframes() {
if (hasConsent()) return;
var iframes = document.querySelectorAll('iframe[src]');
iframes.forEach(function(iframe) {
if (shouldBlock(iframe.src)) {
var placeholder = createPlaceholder(iframe);
placeholder.termsboxOriginalIframe = iframe.cloneNode(true);
if (iframe.width) placeholder.style.width = iframe.width + (isNaN(iframe.width) ? '' : 'px');
if (iframe.height) placeholder.style.height = iframe.height + (isNaN(iframe.height) ? '' : 'px');
iframe.parentNode.replaceChild(placeholder, iframe);
}
});
}
// Run on DOM ready
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', processIframes);
} else {
processIframes();
}
// Also observe for dynamically added iframes
if (typeof MutationObserver !== 'undefined') {
var observer = new MutationObserver(function(mutations) {
if (!hasConsent()) {
mutations.forEach(function(mutation) {
mutation.addedNodes.forEach(function(node) {
if (node.nodeType === 1) {
if (node.tagName === 'IFRAME' && shouldBlock(node.src)) {
var placeholder = createPlaceholder(node);
placeholder.termsboxOriginalIframe = node.cloneNode(true);
node.parentNode.replaceChild(placeholder, node);
}
// Check child iframes
var childIframes = node.querySelectorAll && node.querySelectorAll('iframe[src]');
if (childIframes) {
childIframes.forEach(function(iframe) {
if (shouldBlock(iframe.src)) {
var p = createPlaceholder(iframe);
p.termsboxOriginalIframe = iframe.cloneNode(true);
iframe.parentNode.replaceChild(p, iframe);
}
});
}
}
});
});
}
});
observer.observe(document.body || document.documentElement, { childList: true, subtree: true });
}
})();
</script>
<!-- Get your free Embed Consent tool at https://termsbox.com/embed-consent -->Embed consent is a privacy mechanism that prevents third-party embedded content from loading until users explicitly agree to it. When you embed content from platforms like YouTube, Google Maps, or social media, these embeds often load cookies, tracking scripts, and other data collection mechanisms automatically.
Under privacy regulations like GDPR, ePrivacy Directive, and similar laws worldwide, you need user consent before loading this tracking content. An embed consent tool replaces these embeds with a placeholder that explains what will load and includes a button for users to give consent.
Once consent is given, the original embed loads normally. The tool can remember this choice so returning visitors do not need to consent again on every visit.
Meet EU privacy requirements by getting consent before loading third-party tracking content.
Respect user privacy by not automatically sharing their data with third-party platforms.
Prevent potential GDPR fines by ensuring proper consent for all tracking technologies.
Show users exactly what third-party content will load before they interact with it.
User visits page with embedded content (YouTube, Maps, etc.)
Script detects embeds from blocked domains and replaces with placeholder
Placeholder shows customizable message with consent button
User clicks button to give consent and load all embeds
Consent is saved to localStorage for future visits (if enabled)
YouTube, Vimeo, and other video embeds that set tracking cookies.
Google Maps embeds that track location and user behavior data.
Twitter/X, Facebook, Instagram and other social platform embeds.
Stop loading third-party tracking content without consent. Use our free embed consent tool to stay compliant with privacy regulations.