To embed YouTube videos without using cookies, you can utilize YouTube's Privacy-Enhanced Mode. In this mode, no cookie-related information is stored on the user's device unless the user actively watches the video.
To embed a YouTube video in this mode, follow these steps:
- Open YouTube and locate the video you want to embed.
- Click the 'Share' button below the video.
- In the pop-up window, select 'Embed'.
- Locate and select the 'Enable Privacy-Enhanced Mode' option.
- The system will automatically generate an embed code with a URL using 'https://www.youtube-nocookie.com' instead of the standard 'https://www.youtube.com'.
- Copy this code and paste it into the appropriate location in your webpage's HTML code.
For example, if you want to embed a video, an embed code with Privacy-Enhanced Mode enabled might look like this:
html<iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/VIDEO_ID?rel=0" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
In this code, VIDEO_ID is the ID of the video you want to embed, which you can find in the URL of the YouTube video page.
Please note that even with Privacy-Enhanced Mode enabled, YouTube may still store some information based on user interactions with the video. For example, if the user starts playing the embedded video, YouTube might store information about user behavior. However, compared to standard embedding, this method reduces the impact on user privacy to a significant extent.