WPConsent Documentation

Documentation, Reference Materials, and Tutorials for WPConsent

Content Blocking and Placeholders

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

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:

  1. Removing the iframe source. The src attribute is stripped from matching iframes so the browser doesn’t load them.
  2. Displaying a placeholder. A styled container replaces the iframe with a thumbnail image and a consent button.
  3. 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

Need Support?

Can't find the answer you're looking for?
Contact Support

  

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