Skip to content

Products

Compliance Officer Service Expert-led compliance, end to end Compliance Portal Share security documents securely Open-source platform Deploy Probo on your own infrastructure

Resources

Probo stories How teams get compliant with Probo Blog Ideas and guidance from the Probo team Guides & tools Practical compliance guides and free tools Love from Customers What customers say about working with Probo Changelog Latest product updates Download Get the Probo Agent

Company

About The people and vision powering Probo Careers Join the team building Probo Brand assets Official logos and visual resources Security Review our security and compliance posture
Overview Understand Probo and its core concepts Product Explore Probo's GRC capabilities Developers Explore GraphQL, CLI, MCP, n8n, and webhooks Deployment Probo Cloud, self-hosting, and configuration

Explore

GitHub Explore our open-source compliance tools

Blocking Third-Party Resources

Learn how to gate scripts, iframes, images, and stylesheets behind the data-cookie-consent attribute so they load only after visitor consent.

View as Markdown

The Probo cookie banner SDK can block third-party resources from loading until the visitor grants consent for the corresponding cookie category. This is essential for GDPR and ePrivacy compliance, where non-essential cookies and tracking must not be set before the visitor opts in.

Add a data-cookie-consent attribute to any element you want to gate behind consent. The attribute value must match a cookie category slug from your banner configuration — for example, analytics, advertising, or functional.

The SDK scans the page for elements with this attribute and keeps them inactive until the visitor consents to the matching category. It also watches for dynamically added elements using a MutationObserver, so resources injected after page load are handled automatically.

To block a script, change src to data-src and set type="text/plain" to prevent the browser from executing it:

<!-- Before: loads immediately -->
<script src="https://analytics.example.com/tracker.js"></script>
<!-- After: loads only when "analytics" consent is granted -->
<script
type="text/plain"
data-cookie-consent="analytics"
data-src="https://analytics.example.com/tracker.js"
></script>

If the script originally had a meaningful type attribute (e.g. module), preserve it with data-type:

<script
type="text/plain"
data-type="module"
data-cookie-consent="analytics"
data-src="https://example.com/analytics.mjs"
></script>

Inline scripts work the same way:

<script type="text/plain" data-cookie-consent="analytics">
gtag("config", "GA_MEASUREMENT_ID");
</script>

Replace src with data-src:

<iframe
data-cookie-consent="marketing"
data-src="https://www.youtube.com/embed/VIDEO_ID"
width="560"
height="315"
></iframe>

Tracking pixels and other consent-gated images:

<img data-cookie-consent="analytics" data-src="https://example.com/pixel.gif" />

Replace href with data-href on <link> tags:

<link
data-cookie-consent="analytics"
data-href="https://example.com/tracker.css"
rel="stylesheet"
/>
Element Blocked Attribute Restored To
<script> data-src and/or type="text/plain" src restored, type set to data-type or removed
<iframe> data-src src
<img> data-src src
<video> data-src src
<audio> data-src src
<embed> data-src src
<object> data-src data
<link> data-href href
<script type="text/plain" data-cookie-consent="analytics">
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag("js", new Date());
gtag("config", "GA_MEASUREMENT_ID");
</script>
<script
type="text/plain"
data-cookie-consent="analytics"
data-src="https://www.googletagmanager.com/gtag/js?id=GA_MEASUREMENT_ID"
></script>
<script type="text/plain" data-cookie-consent="advertising">
!function(f,b,e,v,n,t,s){/* Facebook Pixel code */}(window, document, 'script', 'https://connect.facebook.net/en_US/fbevents.js');
fbq('init', 'YOUR_PIXEL_ID');
fbq('track', 'PageView');
</script>
<iframe
data-cookie-consent="functional"
data-src="https://www.youtube.com/embed/VIDEO_ID"
width="560"
height="315"
frameborder="0"
allowfullscreen
></iframe>

The data-cookie-consent attribute value is matched against the category slug in consent state (not the display name). Default categories use these slugs:

Category Attribute Value (slug)
Necessary necessary
Analytics analytics
Advertising advertising
Functional functional
Uncategorised uncategorised

For a custom category, use the slug you set in the console (for example social-media), not the display name.

System categories like Necessary are always consented to, so tagging elements with data-cookie-consent="necessary" is valid but has no blocking effect — those resources load immediately. The Uncategorised category is where cookies that haven’t been assigned to a category yet are collected. You should move cookies out of Uncategorised and into the appropriate category in the console so visitors see meaningful groupings in the preference panel.