Tools

How to embed a YouTube video with autoplay, start time, and privacy

How to get a YouTube embed code and customise it with start times, muted autoplay, looping and privacy-enhanced mode, plus how to make the player responsive on mobile.

Updated October 11, 20267 min readSince 2018

Short answer

The short answer

To embed a YouTube video, click Share under the video, choose Embed and copy the iframe code. Add parameters to the src address to change how it plays, such as start=90 to begin at 90 seconds or autoplay=1&mute=1 for muted autoplay, and use the youtube-nocookie.com domain for privacy-enhanced mode.

The standard way to get an embed code on YouTube

Follow these quick steps on desktop to grab the basic HTML embed code directly from any video.

1Open the video on YouTubeNavigate to the video you want to embed on your computer. Beneath the player title, click the Share button.
2Select the Embed optionIn the Share window, click the first icon labeled Embed (represented by opening and closing brackets). This opens the preview drawer displaying the raw HTML iframe code.
3Configure initial playback settingsBelow the code box, check the box labeled 'Start at' if you want playback to begin at the current video timestamp. You can also toggle 'Show player controls' on or off.
4Enable Privacy-Enhanced ModeCheck the box labeled 'Enable privacy-enhanced mode'. This changes the embed domain from standard youtube.com to youtube-nocookie.com, which limits what YouTube stores about visitors until they play the video.
5Copy the code to your clipboardClick the Copy button in the bottom-right corner. Paste this code directly into your website HTML editor, WordPress custom HTML block, or CMS template.

Useful YouTube iframe embed parameters explained

Add these parameters to the iframe src address. YouTube's player parameter reference documents start, autoplay, controls, loop and rel.

ParameterExample SyntaxFunctionImportant Rule
Start Time?start=90Begins video playback at a specific second count (90 seconds).Must be expressed in total seconds, not minutes and seconds.
Autoplay & Mute?autoplay=1&mute=1Starts video immediately when the web page loads.Browsers usually block autoplay with sound, so add mute=1.
Player Controls?controls=0Hides the bottom control bar, timeline scrubber, and volume slider.Hides the control bar; useful for background loops.
Loop Video?loop=1&playlist=VIDEO_IDRepeats playback continuously from the beginning upon finishing.YouTube's docs say a single video needs playlist set to the same ID, and loop support in embeds is limited.
Related Videos?rel=0Restricts end-screen suggested videos to your channel only.Since 2018, rel=0 shows related videos from the same channel, not zero videos.
Privacy Modeyoutube-nocookie.com/embed/Prevents tracking cookies from being placed before playback.Helps with privacy, but isn't a substitute for a proper cookie consent setup.

Browser autoplay rules: why videos must be muted

Understanding browser media policies prevents broken embeds that fail to play.

Unmuted autoplay is blocked by browsersModern browsers including Google Chrome, Apple Safari, Mozilla Firefox, and mobile operating systems automatically block media from playing sound without explicit user interaction. If you configure an iframe with autoplay=1 without muting, the browser will usually stop it from starting.
The required parameter pairingTo get reliable automatic playback, add both autoplay=1 and mute=1 to your embed link. Browsers generally allow muted autoplay. The mute parameter is widely used, though YouTube's player parameter reference doesn't list it, so test the embed in your target browsers.
Mobile data consumption considerationsKeep in mind that autoplaying video consumes mobile data for visitors on cellular connections. Use autoplay sparingly, such as on dedicated landing page hero sections, rather than on every blog post.

What is privacy-enhanced mode and why should you use it?

When you embed a standard YouTube video using the youtube.com domain, YouTube can set cookies on the visitor's device as soon as your page loads, even if they never press play. For site owners operating in the European Union, United Kingdom, or jurisdictions with strict cookie consent regulations like GDPR and the ePrivacy Directive, loading third-party tracking cookies without prior consent can create a compliance problem.

Checking 'Enable privacy-enhanced mode' swaps the standard domain for youtube-nocookie.com, which limits what YouTube stores about a visitor until they play the video.

Privacy-enhanced mode is completely free, maintains identical video playback performance, and requires zero extra code beyond swapping the domain. Turning it on by default is good practice.

How to make YouTube embeds responsive on mobile

Standard iframes come with fixed width and height dimensions that overflow mobile screens.

The fixed dimension problemDefault YouTube embed codes specify width='560' and height='315'. On a smartphone screen that is only 375 pixels wide, this fixed iframe causes horizontal scrolling and breaks website layouts.
Modern CSS aspect-ratio solutionThe cleanest modern way to make an embed responsive is adding CSS styling directly to the iframe: style='width: 100%; aspect-ratio: 16 / 9; height: auto; border: 0;'. This forces the iframe to adapt to any container width while automatically maintaining the proper widescreen ratio.
The classic padding container wrapperFor older CMS themes, wrap the iframe inside a div container with style='position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;' and give the iframe style='position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: 0;'. The 56.25 percent padding perfectly preserves 16:9 widescreen geometry.

Do embedded YouTube views count toward your channel statistics?

Yes, views generated through embedded players count toward your public YouTube view counts and watch hours, provided the playback is initiated genuinely by a real viewer. When a visitor lands on your blog and clicks play on your embedded video, YouTube logs the view just like a view on the main website.

However, YouTube fraud detection algorithms filter invalid traffic. If you create an autoplaying embedded video that loops invisibly in an iframe or use bots to repeatedly refresh a web page, YouTube invalid traffic filters strip those views from your analytics. Artificially inflating views through deceptive embeds risks demonetization under YouTube Fake Engagement Policy.

Legitimate embeds on popular blogs, educational portals, and partner sites represent high-quality traffic. They bring real viewers who chose to watch.

FAQ

Common questions

See Pricing

To make an embed autoplay, append both ?autoplay=1 and &mute=1 to the iframe source address. Modern browsers automatically block unmuted autoplay to protect user experience.

The youtube-nocookie.com domain is YouTube's privacy-enhanced mode. It limits what YouTube stores about visitors until they play the video, which helps with privacy rules, though it doesn't replace a cookie consent setup.

Yes. Legitimate views generated through embedded players count toward your channel total view count and watch time, provided they are watched by real users and not generated through hidden or fraudulent autoplay loops.

Apply CSS styling to the iframe by setting width to 100 percent and aspect-ratio to 16 / 9. This ensures the video expands to fill mobile screens without cropping or creating horizontal scrollbars.

Not completely. YouTube's docs say that since September 2018 you can't disable related videos. Setting rel=0 limits them to videos from the same channel as the one that just played.

Put it into practice

Start with 1,000 free views on any public video, or run a campaign from $0.10 per 1,000 views. No password, nothing added at checkout.

Get Free Views