How do you stop embedded iframes from loading tracking cookies before visitors give consent? WPConsent blocks third-party iframes and replaces them with visual placeholders that let visitors choose when to load the content. Content blocking and placeholders give you full control over embedded services like YouTube, Vimeo, and Google Maps.
Table of contents
- Prerequisites
- Understanding how content blocking works
- Enabling content blocking
- Choosing which services to block
- Customizing the placeholder button text
- Understanding how placeholders work
- Understanding click-to-consent behavior
- Understanding how content blocking interacts with other features
- Verifying your setup
- FAQ
- Conclusion
Prerequisites
Before you begin, make sure you have:
- WPConsent installed and activated (see our guide on installing WPConsent)
- The consent banner enabled in WPConsent >> Settings
- Enable Script Blocking turned on in WPConsent >> Settings (content blocking relies on the same output buffering process)
- Content Blocking turned on in WPConsent >> Settings with at least 1 service selected
- Administrator access to your WordPress site
Understanding how content blocking works
Content blocking prevents iframes and other embedded elements from loading until the visitor consents to the relevant cookie category. It works alongside automatic script blocking but focuses specifically on embedded content rather than JavaScript tags.
When content blocking is active, WPConsent performs 3 steps for each page request:
- Removing the iframe source. The
srcattribute is stripped from matching iframes so the browser doesn’t load them. - Displaying a placeholder. A styled container replaces the iframe with a thumbnail image and a consent button.
- Restoring the content on consent. When the visitor accepts the relevant cookie category, the original iframe source is restored and the placeholder is removed.
This approach ensures that no data is sent to the third-party service before consent is given. That makes it essential for GDPR, CCPA, and ePrivacy compliance.
Comparing content blocking and script blocking
Script blocking targets tags and prevents JavaScript from executing. Content blocking targets elements and CSS selectors for specific embedded widgets. Both features use the same detection engine and category system. Content blocking also provides a visual placeholder so visitors understand that content is withheld and can choose to load it.
You can enable script blocking and content blocking independently. Script blocking is controlled by the Enable Script Blocking toggle, while content blocking has its own Content Blocking toggle.
Enabling content blocking

To get started:
- Navigate to WPConsent >> Settings in your WordPress admin.
- Scroll to the Content Blocking toggle.
- Turn the toggle on.
- Notice that the Content to Block and Placeholder Button settings appear below the toggle.
- Click Save Changes.
Content blocking requires that script blocking is also enabled. WPConsent uses the same output buffering process for both features. If script blocking is disabled, content blocking has no effect because the page HTML isn't being processed.
Choosing which services to block
WPConsent maintains a remotely updated list of services that support content blocking. The list is fetched automatically and cached locally for 24 hours, so we can add new services without a plugin update.
The following services currently support content blocking:
| Service | Category | What is blocked |
|---|---|---|
| YouTube | Marketing | YouTube video embeds (including youtube-nocookie.com) |
| Vimeo | Marketing | Vimeo video player embeds |
| DailyMotion | Marketing | DailyMotion video player embeds |
| Google Maps | Marketing | Google Maps embed iframes |
| reCAPTCHA | Marketing | Google reCAPTCHA widgets (the .g-recaptcha element) |
All 5 services belong to the Marketing cookie category by default. When a visitor accepts Marketing cookies, all blocked embeds from these services load immediately.
Note: reCAPTCHA is unique among the supported services. Instead of blocking an iframe, WPConsent targets the
.g-recaptchaHTML element and prepends a placeholder before it. The widget itself is hidden until consent is given.
When you enable content blocking, WPConsent shows a Content to Block section with an individual toggle for each supported service. All services are enabled by default.

To change which services are blocked:
- Navigate to WPConsent >> Settings in your WordPress admin.
- Confirm the Content Blocking toggle is enabled.
- In the Content to Block section, toggle each service on or off.
- Click Save Changes.
For example, if you use reCAPTCHA on a contact form and don't want it blocked, disable the reCAPTCHA toggle while keeping YouTube and Vimeo blocked.
Customizing the placeholder button text
You can change the text shown on the placeholder consent button from the settings page.

To update the button text:
- Navigate to WPConsent >> Settings in your WordPress admin.
- Confirm the Content Blocking toggle is enabled.
- Find the Placeholder Button text field.
- Edit the text to your preference.
- Click Save Changes.
The default text is:
Click here to accept {category} cookies and load this content
The {category} tag is a dynamic placeholder that WPConsent replaces with the actual cookie category name. For example, if the blocked iframe belongs to the Marketing category, the button reads: "Click here to accept Marketing cookies and load this content." If you have the Toggle Services setting enabled, the button also mentions the relevant service name so visitors know exactly which service they are accepting.
Understanding how placeholders work
When WPConsent blocks an iframe, it replaces it with a placeholder container. The placeholder has 3 layers:
- Thumbnail image. A background image that gives the visitor a preview of the blocked content.
- Overlay content. A semi-transparent layer over the thumbnail.
- Consent button. A button the visitor can click to accept cookies for that category and load the content.
The placeholder is wrapped in a WPConsent generates relevant thumbnail images for each blocked embed. For video services like YouTube, the thumbnail shows a preview of the specific video. For other services, a generic placeholder image is displayed. Thumbnails are fetched from the WPConsent placeholder API and then saved locally to your server in the If the thumbnail can't be fetched (for example, due to a network error), WPConsent falls back to a default placeholder image bundled with the plugin. The placeholder consent button inherits your banner's accept button colors. WPConsent applies the same CSS variables used by your consent banner ( When a visitor clicks the consent button on a placeholder, WPConsent performs the following: This means clicking 1 YouTube placeholder button also unblocks any other YouTube, Vimeo, Google Maps, or DailyMotion embeds on the same page, because they all share the Marketing category. If the visitor has previously granted consent through the banner, placeholders are never shown. WPConsent checks for existing preferences on page load and restores all matching iframes automatically. Content blocking and script blocking work together. Some services like reCAPTCHA have both scripts and blocked elements. When content blocking is enabled for reCAPTCHA, WPConsent blocks the reCAPTCHA scripts and hides the If you have Google Consent Mode enabled, it doesn't affect content blocking. Google Consent Mode only applies to Google Analytics, Google Ads, and Google Tag Manager scripts. Google Maps iframes are still blocked and replaced with placeholders as normal. When Default Allow is enabled in general settings, all content is unblocked by default. Iframes load immediately and no placeholders are shown. If a visitor then rejects a category, the page reloads and the content is blocked. The website scanner detects embedded content on your site and helps you identify which services you need to manage. Running a scan before enabling content blocking is a good practice to ensure all your services are properly categorized. After enabling content blocking, test your site to confirm everything works correctly: Make sure both Enable Script Blocking and Content Blocking are turned on in WPConsent >> Settings. Content blocking relies on the output buffering started by script blocking. The specific thumbnail likely can't be fetched from the WPConsent API. Verify that your server can make outbound HTTP requests. Thumbnails are stored in Clear any page caching on your site. WPConsent modifies the HTML using output buffering, which runs before most caching layers store their snapshot. If a cached version of the page was created before content blocking was enabled, the iframes still have their original If you block reCAPTCHA, visitors must click the consent button before the reCAPTCHA widget appears. This means forms protected by reCAPTCHA can't be submitted until consent is given. If this is a problem, you can disable reCAPTCHA in the Content to Block list while keeping other services blocked. Content blocking only works for iframes that are present in the page HTML when it first loads. If an iframe is injected by JavaScript after the page loads, WPConsent can't intercept it with this feature because the HTML has already been processed. This is fairly common with widgets and embeds that load dynamically. In those cases, handling consent may require custom code specific to the plugin or theme that creates the iframe, or using a third-party integration like the WP Consent API if the plugin supports it. Yes, but only in the paid version. The paid version lets you add custom script and iframe blocking rules for any service. See our guide on custom script blocking rules for instructions. Content blocking ensures that third-party iframes and embedded widgets don't load until visitors give consent. With visual placeholders, thumbnail previews, and a click-to-consent button, your visitors always understand what content is being withheld and can choose to load it on their terms. To learn how WPConsent handles JavaScript-based tracking scripts alongside content blocking, read our guide on automatic script blocking.wpconsent-iframe-placeholder. The original iframe remains inside the placeholder but has no src, so it doesn't load.
Generating dynamic placeholder images
wp-content/uploads/wpconsent/thumbnails/ directory. This means:
Styling the placeholder button
--wpconsent-accept-bg and --wpconsent-accept-color) to the placeholder button. This ensures the button matches your banner design without any extra configuration.Understanding click-to-consent behavior
data-wpconsent-src attribute is moved back to src, and the iframe loads.wpconsent-iframe-placeholder class is stripped from the container.Understanding how content blocking interacts with other features
Script blocking
.g-recaptcha widget with a placeholder. When the visitor consents, both the scripts and the widget are restored.Google Consent Mode
Default allow (opt-out) mode
Website scanner
Verifying your setup
data-wpconsent-src instead of src.FAQ
Why don't my placeholders appear?
Why do my thumbnails show a generic image instead of a video preview?
wp-content/uploads/wpconsent/thumbnails/. You can delete files there to force a re-download on the next page load.Why does my embedded content load before the visitor gives consent?
src attributes.Why don't my reCAPTCHA forms work after I enable content blocking?
Why isn't an iframe on my page being blocked?
Can I add custom content blocking rules for services not in the default list?
Conclusion