Skip to content

Cookie consent

YouTube embeds and the GDPR: how to add videos with cookie consent

By the Kiescy teamUpdated 6 min readChecked against the official text on

An embedded YouTube video looks harmless: a play button on your page. But the moment the page loads, the visitor's browser connects to Google's servers to fetch the player, sends the visitor's IP address and can receive YouTube's cookies, whether or not they ever press play.

This guide explains when that needs consent, what YouTube's privacy-enhanced mode does and doesn't change, and how to show a placeholder so the real video only loads once the visitor agrees.

The short version

For visitors in the EU and UK, treat embedded YouTube videos as needing consent. The embed loads from Google's servers as soon as the page opens and can store cookies or similar data on the device, which the ePrivacy rules allow only with consent unless strictly necessary. Privacy-enhanced mode (youtube-nocookie.com) reduces personalisation, but Google doesn't document it as cookie-free. The safe setup is a click-to-load placeholder that loads the video only after consent.

Words you'll see in this guide (4)
Embed:
A YouTube player placed on your page with an <iframe>. It's YouTube's code running inside your site.
Privacy-enhanced mode:
Embedding from youtube-nocookie.com instead of youtube.com. Google says views then don't influence the viewer's YouTube experience and ads are non-personalised.
Click-to-load placeholder:
A preview image and a button shown in place of the video. The real player only loads when the visitor clicks or allows the cookie category.
ePrivacy rule:
Article 5(3) of the EU ePrivacy Directive (and the UK's PECR): storing or reading anything on a visitor's device needs consent unless it's strictly necessary for a service they asked for.
On this page
  1. Why it needs consent
  2. youtube-nocookie.com
  3. Click-to-load setup
  4. Alternatives
  5. Your policy
  6. Test it
  7. Questions
  8. Sources

Why a YouTube embed needs consent

Two separate things happen when a page with a YouTube embed loads, and both matter in Europe:

  • Your visitor's data goes to Google. The browser requests the player from Google's servers, which see the visitor's IP address and device details. An IP address can be personal data under the GDPR (Article 4(1) and recital 30).
  • Something is stored on the device. The player can set cookies or use local storage. Under Article 5(3) of the ePrivacy Directive, and the UK's PECR, that needs consent unless it's strictly necessary for something the visitor asked for. A video they haven't clicked yet isn't that.

That's why European data protection authorities and most consent tools treat video embeds as needing consent, usually in a category such as "social", "media" or "marketing". In the US, there's no general consent rule for embeds, but a privacy policy that mentions YouTube is still expected.

Example

A yoga studio in Dublin embeds three class videos on its homepage. Before any visitor clicks anything, their browser has already contacted YouTube three times. With a placeholder, the homepage shows three thumbnails with a "Load video" button, and YouTube is only contacted for the video the visitor chooses to watch.

Does youtube-nocookie.com make embeds GDPR compliant?

Not on its own. YouTube's help page describes privacy-enhanced mode like this: you change the embed address from https://www.youtube.com to https://www.youtube-nocookie.com, views of the video then don't influence the viewer's YouTube browsing experience, and ads shown are non-personalised.

What the help page doesn't say is that no cookies or device storage are used, or that no data reaches Google. The player still loads from Google's servers, so the IP address still goes to Google.

Standard embed (youtube.com)Privacy-enhanced (youtube-nocookie.com)
Player loads from Google when the page opensYesYes
Visitor's IP address reaches GoogleYesYes
Views influence the viewer's YouTube recommendationsYesNo, according to YouTube
Personalised ads in the playerPossibleNo, according to YouTube
Documented as cookie-freeNoNo

So use privacy-enhanced mode, because it collects less, and still put the video behind consent for EU and UK visitors.

If your site is aimed at children, YouTube's help page says you must still mark it as child-directed, even with the privacy-enhanced player.

How to add a click-to-load placeholder

A placeholder keeps the page looking finished while the video waits. The visitor sees a thumbnail and a short note, and the real player loads only after they agree.

A placeholder box saying This video is hosted by YouTube, loading it lets YouTube set cookies, with a Load video button. Until the visitor clicks or allows the category, no request goes to Google. After that, the YouTube player loads and can set cookies.This video is hosted by YouTubeLoading it lets YouTube set cookiesLoad videoNo request to Google yetafter click or consentEmbed loads, cookies set
Until the visitor agrees, the browser never contacts YouTube.

With Kiescy

Rename the iframe's src to data-pira-src and add the category. Kiescy keeps the address off the iframe until the visitor allows that category, then sets it, so the browser never contacts YouTube before consent:

Embed that waits for consent
<iframe
  data-pira-category="social"
  data-pira-src="https://www.youtube-nocookie.com/embed/VIDEO_ID"
  title="Class preview video"
  width="560" height="315"
  allow="accelerometer; encrypted-media; picture-in-picture"
  allowfullscreen></iframe>

Once the video is released, Kiescy adds data-pira-released="1" to the iframe. Use that to show your placeholder only while the video is waiting:

Placeholder styling
/* An empty iframe shows a grey box with a short note until consent */
iframe[data-pira-category]:not([data-pira-released]) {
  background: #f4f4f5 url(/img/video-placeholder.jpg) center / cover;
  aspect-ratio: 16 / 9;
  height: auto;
}

Tip: Use your own thumbnail image, saved on your server. Loading the thumbnail from YouTube's image servers (i.ytimg.com) would contact Google before consent, which is what you're trying to avoid.

On WordPress, Shopify and site builders

WordPress adds YouTube videos through the Embed block, which writes a normal iframe. Switch the block to Edit as HTML (or use a Custom HTML block) and use the code above. On Shopify, Wix, Squarespace and Webflow, use their custom code or HTML embed element instead of the built-in video block, because the built-in blocks load YouTube straight away. Our install guides show where each platform keeps its custom code.

Other ways to show videos without the consent problem

OptionGood forWatch out for
Click-to-load placeholderMost sites that want YouTube's reachYou need your own thumbnails
A linked thumbnail that opens YouTube in a new tabSimple pages, blogsVisitors leave your site to watch
Self-hosted video (MP4 on your server or CDN)Short clips, product demosBandwidth and storage costs
A video host that offers cookieless embedsCourses, paid contentCheck its own privacy documentation, not just the marketing page

What to say in your privacy and cookie policy

Name YouTube (Google) as a third party, say what it receives (IP address, device data, viewing activity once the video loads), that it loads only after consent, and link to Google's privacy policy. If you keep a cookie policy, list YouTube under the same category your banner uses. Our free cookie policy generator has YouTube preset, and cookie policy vs privacy policy explains what goes where.

How to check it's working

  1. Open the page in a private window.
  2. Open DevTools → Network and type youtube in the filter box.
  3. Before you agree to anything, there should be no requests to youtube.com, youtube-nocookie.com, ytimg.com or googlevideo.com.
  4. Allow the category (or click your placeholder). The player requests should appear now.

The free website check does the same test across the whole page, and our guide to checking which cookies a website sets walks through the manual method in every browser.

Questions

Does YouTube set cookies if the visitor doesn't press play?

It can. The player loads as soon as the page opens, and the browser contacts Google then, not when play is pressed. That's why the video should wait for consent.

Is youtube-nocookie.com GDPR compliant?

It reduces personalisation, but YouTube doesn't document it as cookie-free, and the visitor's IP address still reaches Google. Use it together with a consent placeholder for EU and UK visitors.

Which cookie category should YouTube go in?

Most sites use a social media or marketing category. Kiescy uses "social". Whatever you choose, describe it the same way in your banner and your cookie policy.

Do I need consent for YouTube videos in the US?

There's no general US consent rule for embeds. Mention YouTube in your privacy policy, and honour opt-outs if you're covered by a state privacy law.

Does the same apply to Vimeo and other video hosts?

Yes, the same rule applies to any embed that loads from another company's servers and can store data on the device. Check the host's own documentation; some offer a cookieless player setting.

Sources

The facts in this guide come from these official sources, last checked on . We review the guide whenever they change.

  1. YouTube Help: Embed videos & playlists (privacy-enhanced mode)
  2. ePrivacy Directive 2002/58/EC, Article 5(3) (EUR-Lex)
  3. General Data Protection Regulation (EU) 2016/679, Article 4(1) and recital 30 (EUR-Lex)

See what your videos load

Our free check loads your page without consent and lists every request to YouTube and Google before the visitor agrees.

Open the free tool

This guide explains the law in general terms and isn't legal advice. Laws change and how they apply depends on your situation; for high-risk processing, ask a lawyer.

Keep reading

All guides

Get compliant this afternoon, not this quarter.

Set up your policies, banner and request form in one place. Free while Kiescy is in early access.