TermsBox
PricingBlog
LoginGet Started
PricingBlogLogin
Get Started
100% FREE

Free Embed Consent Tool

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.

Build Your Embed Consent Tool

Configure your embed consent tool below. Copy the generated code and add it to your website.

Configuration
Choose which embeds to block and customize the appearance
Preview

This content is blocked until you accept cookies

Generated Code
Copy this code and paste it before the closing </body> tag
<!-- 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 -->

Installation Instructions

  1. Copy the code above
  2. Paste it before the closing </body> tag on your pages
  3. The script will automatically find and block matching embeds
  4. Test by visiting a page with YouTube or other embeds

What Is 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.

Why You Need Embed Consent

GDPR Compliance

Meet EU privacy requirements by getting consent before loading third-party tracking content.

User Privacy

Respect user privacy by not automatically sharing their data with third-party platforms.

Avoid Fines

Prevent potential GDPR fines by ensuring proper consent for all tracking technologies.

Transparency

Show users exactly what third-party content will load before they interact with it.

How It Works

1

User visits page with embedded content (YouTube, Maps, etc.)

2

Script detects embeds from blocked domains and replaces with placeholder

3

Placeholder shows customizable message with consent button

4

User clicks button to give consent and load all embeds

5

Consent is saved to localStorage for future visits (if enabled)

Supported Platforms

Video Platforms

YouTube, Vimeo, and other video embeds that set tracking cookies.

Google Maps

Google Maps embeds that track location and user behavior data.

Social Media

Twitter/X, Facebook, Instagram and other social platform embeds.

Frequently Asked Questions

Make Your Embeds GDPR Compliant

Stop loading third-party tracking content without consent. Use our free embed consent tool to stay compliant with privacy regulations.

Related Privacy Tools

Cookie Consent Banner

Complete cookie consent solution with customizable banner and preferences.

CCPA Opt-Out Link

Add a "Do Not Sell My Personal Information" link for California compliance.

Privacy Policy Generator

Generate a comprehensive privacy policy tailored to your business needs.

TermsBoxBy Lunera

Automated compliance for modern websites.

Lunera AS

Org. nr. 936863590

Sigurd Hoels Vei 8, 0655 Oslo, Norway

Products

  • Privacy Policy Generator
  • Terms and Conditions Generator
  • Cookie Policy Generator
  • EULA Generator
  • Disclaimer Generator
  • Return and Refund Policy Generator
  • Terms of Service Generator
  • Terms of Use Generator

Legal

  • Privacy Policy
  • Terms of Service
  • Disclaimer
  • Cookie Policy
  • Refund Policy

Company

  • About
  • Contact

2026 TermsBox by Lunera AS. All rights reserved.