Cookies & tracking
YouTube embeds and cookies: privacy-enhanced mode and consent
A standard YouTube embed sets cookies and contacts Google as soon as the page loads. Privacy-enhanced mode (youtube-nocookie.com) reduces this but still sends data to Google and uses browser storage, so in the EU and UK you should still load embeds only after consent or a click.
- Plain English
- Written for website owners
- Free to read
On this page
A standard YouTube embed loads YouTube's player from youtube.com as soon as your page loads. That sets cookies, uses browser storage and sends the visitor's IP address and the page URL to Google, before anyone presses play. Privacy-enhanced mode, which uses youtube-nocookie.com, changes how Google uses the viewing data, but it doesn't stop data flowing to Google or storage being used. In the EU and UK, the safe approach is to load the player only after the visitor consents or clicks to load it.
What a standard embed does on page load
The usual embed code is an iframe pointing at https://www.youtube.com/embed/VIDEO_ID. When the browser renders it, the player:
- loads scripts, styles and images from Google domains such as
youtube.com,ytimg.comandgooglevideo.com, - sets cookies on
youtube.comthat are commonly reported by scanners, such asYSCandVISITOR_INFO1_LIVE, - writes entries to local storage and IndexedDB under YouTube's origin, and
- can read existing YouTube or Google cookies if third-party cookies are allowed, which links the embed to the visitor's Google account.
Exact cookie names change over time and differ by browser and region, so verify against your own scan. The point is that all of this happens on page load, without any action from the visitor. In the EU and UK, storage and access for purposes beyond showing the video you asked for needs consent under Article 5(3) of the ePrivacy Directive or PECR regulation 6.
What privacy-enhanced mode changes
You enable privacy-enhanced mode by changing the domain in the embed URL from youtube.com to youtube-nocookie.com. YouTube's help documentation says that in this mode:
- views of the embedded video aren't used to personalize the viewer's YouTube experience, either in the embed or on YouTube itself,
- ads shown in the embed are non-personalized, and
- the views aren't used to personalize ads shown to the viewer elsewhere.
That is a meaningful reduction. It's also narrower than the domain name suggests. Google's description is about how viewing data is used. It doesn't promise that nothing is stored on the device, and it notes that once a viewer clicks through to YouTube or another site, that site's own policies apply.
What privacy-enhanced mode doesn't change
Cookie scans of youtube-nocookie.com embeds typically show fewer or no cookies on page load, but they often show other storage:
- Local storage and IndexedDB entries under the
youtube-nocookie.comorigin, such as player settings and device identifiers. As the guide to localStorage and consent explains, web storage is covered by the same rule as cookies. - Requests to Google's servers, which reveal the visitor's IP address, user agent and, depending on your referrer policy, the page they're on.
- Normal YouTube behavior after interaction. Clicking the YouTube logo or "Watch on YouTube" takes the visitor to YouTube with its usual cookies.
So privacy-enhanced mode is a good default, but not a substitute for consent in opt-in regions. Use it and hold the embed back until the visitor agrees.
Treat youtube-nocookie.com as "less tracking", not "no tracking". It is worth using, but it doesn't remove the need to wait for consent or a click.
Three ways to hold embeds back
You can block the player until the visitor accepts a cookie category, show a placeholder that loads the player on click, or skip the embed and link to YouTube. Many sites combine the first two.
Option 1: Block the iframe until consent
The simplest fix with a consent tool is to keep the iframe's URL out of src until the visitor allows the right category. With PrivacyQuick, you move the URL to data-src and add a data-category. The script blocking docs show the exact markup, including a short placeholder message with a link that reopens the cookie settings.
The downside is that a visitor who rejected the category sees an empty box where the video should be. Some will reopen the settings and accept. Many won't. That's why many sites combine blocking with a click-to-load placeholder.
Option 2: A click-to-load placeholder
A click-to-load placeholder, sometimes called a facade or "two-click" embed, shows a static image with a play button and a short notice. Nothing loads from YouTube until the visitor clicks. The click is a clear, specific action, and the notice tells them what will happen, which is why many sites treat it as consent for that video. This approach is common in Germany and elsewhere in Europe.
Here's a minimal version. It uses a thumbnail you host yourself, so nothing is requested from Google before the click:
<div data-yt-video="VIDEO_ID">
<button type="button">
<img src="/images/video-tour-thumb.jpg" alt="Play video: Product tour (2:14)" width="560" height="315">
</button>
<p>Playing this video loads content from YouTube (Google), which may store data on your device and send Google information about your visit.</p>
</div>
<script>
document.querySelectorAll('[data-yt-video]').forEach(function (box) {
box.querySelector('button').addEventListener('click', function () {
var iframe = document.createElement('iframe');
iframe.src = 'https://www.youtube-nocookie.com/embed/' +
encodeURIComponent(box.dataset.ytVideo) + '?autoplay=1';
iframe.width = 560;
iframe.height = 315;
iframe.title = 'YouTube video player';
iframe.allow = 'autoplay; encrypted-media; picture-in-picture; fullscreen';
iframe.referrerPolicy = 'strict-origin-when-cross-origin';
box.replaceWith(iframe);
});
});
</script>
A few details make this work well:
- Self-host the thumbnail. Loading it from
i.ytimg.comsends the visitor's IP address to Google before they choose. Save the thumbnail once and serve it from your own domain. - Keep the button accessible. Use a real
<button>, describe the video in the image's alt text and keep the notice visible, not in a tooltip. - Use
autoplay=1so the visitor doesn't have to click twice. Because the iframe is created in response to a click and itsallowattribute includes autoplay, browsers usually let it start playing. - Respect existing consent. If the visitor has already allowed the category you use for video, you can skip the placeholder and load embeds immediately, for example by checking
PrivacyQuick.has('marketing')on load.
Facades are also good for speed. A YouTube player downloads a substantial amount of JavaScript, so showing a static image until the visitor clicks often improves page load metrics. The guide to cookie banners and page speed covers related performance issues.
Option 3: Link instead of embedding
For a video that isn't central to the page, a thumbnail that links to the video on YouTube avoids the issue entirely. The visitor leaves your site and YouTube's own consent flow applies. This is the lowest-effort option for blog posts that reference videos in passing.
Pitfalls that let YouTube load early
Sites that think they've handled embeds often still contact Google before consent. The usual causes:
- The IFrame Player API script. If your site controls players with JavaScript, it probably loads
https://www.youtube.com/iframe_api. That script comes fromyoutube.com, not the privacy-enhanced domain, and loads on every page that includes it. Block it until consent, or load it only when the visitor clicks play. - Lazy loading.
loading="lazy"on an iframe delays it until the visitor scrolls near it. That helps performance, but scrolling isn't consent. The embed still loads without any choice being made. - Page builders and oEmbed. Pasting a YouTube URL into WordPress, Webflow or similar tools usually produces a standard
youtube.comembed automatically. Check the generated markup, not just the URL you pasted. - Thumbnails and previews. Link previews, video galleries and "featured video" widgets often pull images from
i.ytimg.com, which sends a request to Google even without a player. - Background and hero videos. Autoplaying muted videos used as decoration are easy to forget because nobody "plays" them. If they come from YouTube, they need the same treatment, or better, a self-hosted video file.
The quickest way to find these is to load each template in a private window with the Network tab filtered for youtube and ytimg, before touching the banner.
Choosing a category
Sites disagree on where video embeds belong, and both common choices are defensible:
| Category | Reasoning | Trade-off |
|---|---|---|
| Marketing | YouTube is an advertising business and may use data for ads, even if non-personalized in privacy-enhanced mode. | Visitors who reject marketing won't see videos until they click to load. |
| Functional | The embed provides content the visitor wants to watch. | You must explain clearly that the provider may use data for its own purposes. |
What matters most is that your cookie policy describes the category and the provider accurately. The guide to cookie categories explains how to classify borderline tools.
US considerations
There's no general US opt-in rule for embeds. However, video embeds and video analytics have been the subject of lawsuits under the federal Video Privacy Protection Act, in which plaintiffs argue that sharing which videos a logged-in user watched with a third party is a disclosure the law restricts. The outcome depends heavily on the facts, and courts have reached different results. The overview of website wiretapping lawsuits covers VPPA claims in more detail. If you host videos for logged-in subscribers, take legal advice on how embeds and pixels interact.
Other embeds follow the same logic: see Google Maps, Vimeo and other embeds.
Embedded forms and scheduling tools raise the same questions: see Typeform, Calendly and embedded forms.
Checklist
- Switch every embed to
youtube-nocookie.com. - Hold embeds back until consent or a click, using
data-srcblocking, a facade, or both. - Self-host thumbnails so no request reaches Google before the visitor chooses.
- Give video embeds a category and describe YouTube as a provider in your cookie policy.
- Check page builders and plugins that insert embeds automatically, and replace their markup where needed.
- Run a free cookie scan to confirm nothing from YouTube loads before consent.
Frequently asked questions
Is youtube-nocookie.com GDPR compliant?
No embed domain is compliant or non-compliant by itself. Privacy-enhanced mode reduces tracking, but it still sends the visitor's IP address to Google and can use browser storage, so in the EU you still need consent or a click-to-load step.
Should YouTube embeds go in the marketing or functional category?
Either can be defensible. Marketing reflects YouTube's advertising use of data; functional reflects that the visitor wants to watch a video. Pick one, describe it accurately in your cookie policy and use it consistently.
Do Vimeo and other video embeds have the same issue?
Often, yes. Most hosted players set cookies or use storage and send viewing data to the provider. Vimeo offers a do-not-track parameter (dnt=1) that limits this, but check what each player actually does with a scan.
Does a YouTube thumbnail image need consent?
Loading a thumbnail from YouTube's image servers sends the visitor's IP address to Google, though it sets no cookies. Many sites self-host the thumbnail so that nothing is requested from Google until the visitor clicks play.
Check your own website in 30 seconds
Our free scanner lists every cookie and tracker your site sets, sorted into categories, before you add a banner.
This guide is general information, not legal advice. Laws and regulator guidance change; check the current rules for your situation or ask a lawyer.