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
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.
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.
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:
<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:
/* 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
| Option | Good for | Watch out for |
|---|---|---|
| Click-to-load placeholder | Most sites that want YouTube's reach | You need your own thumbnails |
| A linked thumbnail that opens YouTube in a new tab | Simple pages, blogs | Visitors leave your site to watch |
| Self-hosted video (MP4 on your server or CDN) | Short clips, product demos | Bandwidth and storage costs |
| A video host that offers cookieless embeds | Courses, paid content | Check 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
- Open the page in a private window.
- Open DevTools → Network and type
youtubein the filter box. - Before you agree to anything, there should be no requests to youtube.com, youtube-nocookie.com, ytimg.com or googlevideo.com.
- 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.
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 toolThis 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.