Skip to content
FunnelGuard

Fix guide by FunnelsGuard

YouTube and Maps embeds setting cookies before consent: fix

OPS-339Medium impactPartlyBy FunnelGuardPublished Updated
On this page

What this issue is

A third-party embed is a piece of another company's content shown inside your page, usually through an iframe. Common ones are YouTube videos, Google Maps, Vimeo, Calendly, social feeds and chat widgets.

When the page loads, the visitor's browser connects to the embed provider straight away. The provider can set cookies or read identifiers, and it sees the visitor's IP address. Under the ePrivacy rules (which apply in the EU and, through UK PECR, in the UK), storing or reading non-essential cookies needs prior consent. If this happens before the visitor clicks anything in your cookie banner, you have a consent problem.

Why it costs you leads or sales

The direct cost is risk: regulators and complainants can point to cookies set without consent, and the fix is easy to demand. The indirect costs matter for marketing teams too.

How it hurts the business
  • Your banner says no cookies until consent, but the page behaves differently. That breaks trust and can undermine consent records.
  • Visitors who reject cookies still get tracked by the embed, so your cookie list and privacy policy are inaccurate.
  • A fix done in a rush (blocking the whole page script) can break the video or map, or the lead form next to it.
  • Embeds add third-party requests that slow the page, which can lower conversions on landing pages.
How an embed sets cookies before consent
  1. Visitor opens pagePage HTML loads with an iframe in it
  2. Embed loadsBrowser contacts youtube.com or google.com
  3. Cookie setProvider stores or reads identifiers
  4. Banner choiceVisitor rejects, but it is too late

The embed loads on page load, so the cookie is set before the banner choice is made.

How to check if your site has it

Test as a first-time visitor who has not accepted anything. Use a private window so old cookies do not hide the problem.

Check by hand in Chrome
  1. Open a private window

    Visit a page with a YouTube video or map. Do not click anything in the cookie banner.

  2. Open DevTools

    Press F12, then go to Application > Cookies. Look at entries for youtube.com, google.com, doubleclick.net or the embed provider.

  3. Check the Network tab

    Reload with the Network tab open and filter by the provider name. Requests that appear before you interact with the banner show the embed loading without consent.

  4. Repeat after rejecting

    Clear cookies, reload, click Reject all, and look again. Cookies or requests that still appear are not honouring the choice.

  5. Search your code for embeds

    Look in templates and page content for <iframe, youtube.com/embed, google.com/maps/embed and any embed plugins.

How to fix it

There are two reliable approaches. Pick one per embed.

Ways to stop embeds setting cookies early
ApproachHow it worksBest for
Block until consentYour consent tool keeps the iframe from loading until the visitor accepts the matching categorySites with a working consent platform
Click-to-load placeholderA static image and a button replace the embed; the iframe loads only on clickAny site, and it also speeds up the page
youtube-nocookie.comYouTube's privacy-enhanced mode delays some cookies until playbackExtra layer only, not a full fix on its own
Replace with a link or static imageLink to the video or show a static map imagePages where the embed is not essential
Fix by platform
  1. Use your consent plugin's blocking

    Most consent plugins (for example Complianz, CookieYes, Cookiebot) have a setting to block iframes until consent and show a placeholder. Turn on the YouTube and Google Maps services in the plugin.

  2. Check page builders and embed blocks

    Elementor, Divi and the block editor YouTube embed can load iframes outside the plugin's reach. Re-test in a private window after changing settings.

  3. Switch to privacy-enhanced mode

    In the YouTube embed URL, change youtube.com to youtube-nocookie.com as an extra layer.

Click-to-load YouTube placeholderhtml
<div class="yt-consent" data-src="https://www.youtube-nocookie.com/embed/VIDEO_ID?autoplay=1">
  <p>This video is hosted by YouTube. Loading it may set cookies.</p>
  <button type="button">Load video</button>
</div>
<script>
  document.querySelectorAll('.yt-consent button').forEach(function (btn) {
    btn.addEventListener('click', function () {
      var box = btn.closest('.yt-consent');
      var frame = document.createElement('iframe');
      frame.src = box.dataset.src;
      frame.width = '560';
      frame.height = '315';
      frame.allow = 'autoplay; encrypted-media; picture-in-picture';
      frame.allowFullscreen = true;
      box.replaceChildren(frame);
    });
  });
</script>
Embed behaviour before and after

Before

  • Iframe loads on page load
  • Cookies appear before any banner choice
  • Rejecting cookies changes nothing for the embed

After

  • Placeholder shown until click or consent
  • No requests to the provider before the choice
  • Rejecting keeps the embed blocked

How to confirm it's fixed

Confirm the fix
  1. Test a clean first visit

    In a new private window, open the page and do not touch the banner. In DevTools, there should be no cookies and no network requests to youtube.com, google.com/maps or the provider.

  2. Test Reject all

    Click Reject all and reload. The embed should still show the placeholder.

  3. Test Accept

    Accept the matching category. The embed should now load and play or show the map.

  4. Test on mobile

    Repeat on a phone, as some themes load different embeds on small screens.

How to prevent it happening again

Prevention habits
  • Keep a list of every embed on the site and the consent category each one belongs to.
  • Add a click-to-load pattern to your theme or page templates, so editors do not paste raw iframes.
  • Tell editors not to paste embed codes from YouTube or Maps directly into pages.
  • Re-test in a private window after theme, plugin or consent tool updates.
  • Review your cookie policy when you add a new embed type.

How FunnelGuard handles this

FunnelGuard detects this issue only partly. Its robot visitor can run a consent-denied variant of your journey, and in that variant it checks whether tracking hits are still sent to ad and analytics platforms (GA4, Google Ads, Meta, TikTok, LinkedIn, Bing, Pinterest, Snapchat, X, Reddit). If hits appear after consent is denied, you get an alert with a screenshot and a likely cause.

What it does not do: it does not list the cookies that YouTube, Google Maps or other embeds set, and it does not tell you whether an iframe loaded before the banner choice. A clean consent-denied run therefore does not prove your embeds are compliant.

Cover the rest by hand
  1. Run the private-window check

    Follow the DevTools steps above on every page type that holds an embed, before and after rejecting.

  2. Re-check after changes

    Repeat after theme, plugin, page builder or consent tool updates, and when editors add new pages.

  3. Record the result

    Note the date, pages tested and what you found, so you can show the checks were done.

The Free plan (1 site, 2 journeys, daily checks, no card) is enough to try the consent-denied check. A free read-only website audit is also available.

Questions people ask

Does a YouTube embed set cookies before consent?

It can. A standard YouTube iframe connects to Google servers when the page loads and may set cookies or read identifiers, before the visitor has agreed. Test it in a private window and look in DevTools under Application > Cookies.

Is youtube-nocookie.com GDPR compliant?

Not automatically. Privacy-enhanced mode limits some cookies until the video is played, but the browser still contacts Google when the page loads. Use it as an extra layer alongside consent blocking or a click-to-load placeholder.

Does Google Maps need cookie consent?

A standard Google Maps embed loads Google resources and can set cookies, so many sites treat it as needing consent. Block it until the visitor agrees, or show a static image with a link to the map. Ask your legal adviser how to categorise it.

How do I block an iframe until cookie consent is given?

Keep the iframe URL out of the src attribute until consent. Your consent tool can do this by category, or you can use a placeholder with a button that sets the src on click. Then confirm in DevTools that nothing loads before the choice.

How do I check which cookies my embeds set?

Open the page in a private window without touching the banner. Press F12 and open Application > Cookies, then look at the Network tab for requests to the embed provider. Repeat after clicking Reject all.

Can Google Tag Manager block my YouTube embed?

Only if GTM inserts the embed. An iframe written directly into the page loads regardless of GTM. Remove it and have a consent-gated Custom HTML tag add it after consent.

Does FunnelGuard detect embeds setting cookies before consent?

Only partly. It runs a consent-denied variant and flags tracking hits that still fire to ad and analytics platforms. It does not list cookies set by embeds such as YouTube or Maps, so you need to check those by hand.

Does FunnelGuard catch this?

Partly

FunnelGuard checks part of this.

How: Consent-denied variant sees hits.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.