WPConsent Blog

Everything you need to know about the WPConsent plugin

How to Block YouTube Cookies Before Consent in WordPress

How to Block YouTube Cookies Before Consent in WordPress 

Adding YouTube videos to my WordPress site seemed simple at first, until I noticed a significant privacy issue. Every time a visitor landed on a page with an embedded YouTube video, cookies were being placed on their device without consent.

This became a real problem when European visitors started raising concerns about GDPR compliance. Not only was I potentially violating privacy laws, but I was also making my site less trustworthy in the eyes of privacy-conscious users.

However, with the right cookie plugin like WPConsent, you can easily handle YouTube cookies in WordPress. Instead of removing YouTube videos altogether or compromising user experience, you control exactly how and when YouTube cookies are loaded on your site.

In this article, I’ll show you how to block YouTube cookies before consent in WordPress, maintain GDPR compliance, and give your visitors the privacy choices they deserve.

Why Block YouTube Cookies in WordPress?

When you embed YouTube videos on your WordPress site, they come with more than just video content. Every embedded video automatically loads tracking cookies from YouTube, whether your visitors watch the video or not.

Think of these cookies like small digital footprints that follow your visitors around the web. They track viewing habits, preferences, and other personal data that many users would rather keep private.

Privacy laws like GDPR require you to get explicit consent before placing non-essential cookies on your visitors’ devices. Simply embedding a YouTube video without proper cookie controls could lead to hefty fines.

I’ve seen many site owners struggle with this requirement. Some remove YouTube videos completely, while others ignore the rules and hope for the best. Neither approach is ideal for your website or your visitors.

That said, let’s see how you can easily prevent YouTube cookies from loading until a user gives consent.

Prevent YouTube Cookies in WordPress Before Consent

The easiest way to block YouTube cookies from loading before consent in WordPress is by using WPConsent. It is a powerful cookie consent plugin that helps you scan scripts that add cookies to your site, create stunning cookie banners, and comply with different privacy laws.

What sets it apart is its ability to handle cookies from popular video platforms, including YouTube, Dailymotion, and Vimeo. This means is that WPConsent will automatically block content that use iframes from loading until a user grants consent. 

Besides YouTube and other video services, WPConsent also works seamless with Google Maps and reCAPTCHA. It stops content embedded as iframes on your site from these services from loading before consent.

Note: For this tutorial, I’ll use the WPConsent Pro version because it offers advanced features, like viewing consent logs, automatic detection for Cloudflare, WooCommerce and WPForms, modal banner template, and more. However, there is also WPConsent Lite version which you can use for free, and it also includes the content blocking feature.

First, you’ll need to install and activate the WPConsent plugin. If you need help, then please see this guide on how to install a WordPress plugin.

Upon activation, you’ll see the WPConsent setup wizard. Go ahead and click the ‘Let’s Get Started’ button and follow the onscreen instructions.

WPConsent setup wizard

Once you’ve set up the plugin, you can head to WPConsent » Settings from the WordPress admin panel.

From here, you can scroll down to the ‘Content Blocking’ section.

Enable content blocking option

Go ahead and click the toggle to enable Content Blocking.

Next, you will see different content providers, including YouTube, Vimeo, Dailymotion, Google Maps, and reCAPTCHA.

Select services in content blocking

By default, all the services will be enabled, but you can choose which one’s to block on your site. Just ensure that YouTube is enabled under the Content to Block list.

WPConsent will also show an option to edit the Placeholder Button text. This is the text that will appear on the YouTube video on your site that visitors will see.

Once you’ve made the changes, don’t forget to save them. From here, simply visit your site to see Content Blocking in action.

View content blocking placeholder

For instance, when a visitor views a page with a YouTube video on your site, they’ll need to click on the video to accept cookies and load the content. They can also click the ‘Accept’ button in the cookie consent banner to load the video.

That’s it, you’ve successfully stopped YouTube from loading cookies before consent in WordPress.

I hope this article helped you learn how to block YouTube cookies before consent in WordPress. You may also want to see our guide on how to add a cookie consent banner to your WordPress website and how to block third party cookies on your WordPress site.

If you liked this article, then please follow us on X (formerly known as Twitter). You can also leave a comment below if you need any assistance.

Add A Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.


Popular Resources

Get free tips and resources right in your inbox, along with 500+ others

Follow Us