Blocking
Block scripts manually
Hold any script or iframe until a visitor allows its category: change type to text/plain, add data-category, and use data-src for embeds like videos and maps.
You can hold any script or iframe until a visitor allows its category. Change two attributes on the tag, and allowedit loads it only after consent, and again on every later page view once the choice is stored.
Most sites need this for little or nothing: auto-blocking already holds 40+ known trackers. Use manual blocking for your own scripts, smaller vendors and inline snippets that auto-blocking can't recognise.
The categories
| Category | Use it for |
|---|---|
preferences | Remembering choices: language, region, chat widgets that store settings |
analytics | Measuring visits: analytics, heatmaps, session recording |
marketing | Advertising and retargeting pixels, social embeds, video players that track |
necessary scripts always run, so don't mark them. Anything the site needs to work (login, cart, security) belongs there.
statistics also works as another name for analytics, so tags written for other consent tools with data-category="statistics" work without changes.
Block an external script
Change type to text/plain and add data-category:
<!-- Before -->
<script src="https://cdn.example-analytics.com/tracker.js"></script>
<!-- After -->
<script type="text/plain" data-category="analytics" src="https://cdn.example-analytics.com/tracker.js"></script>
The browser doesn't run a script whose type is text/plain. When the visitor allows analytics, allowedit turns it into a normal script and runs it. Attributes like async, defer and id are kept.
Block an inline script
Inline snippets work the same way:
<script type="text/plain" data-category="marketing">
!function(w,d){ /* the vendor's pixel snippet */ }(window, document);
</script>
Inline scripts run in the order they appear once their category is allowed.
Block an ES module
A blocked script loses its type="module", because its type is text/plain. Add data-type="module" and allowedit runs it as a module once its category is allowed:
<script type="text/plain" data-category="analytics" data-type="module" src="/js/analytics.mjs"></script>
It works for inline modules too.
Block an iframe
For embeds such as videos, maps, booking widgets and social posts, move the URL from src to data-src and add data-category:
<iframe
data-src="https://player.example.com/embed/123"
data-category="marketing"
width="560"
height="315"
title="Product video"
></iframe>
Until the visitor allows marketing, the frame shows a placeholder with a short message and a button. Clicking the button asks the visitor to allow the category, then loads the embed. You can change the placeholder text in your dashboard, under Banner, then Text.
Keep width, height and title on the iframe so the layout doesn't jump when it loads.
What happens when consent changes
- Allowed: blocked scripts and iframes in that category load straight away, without a page reload.
- Withdrawn: scripts that already ran can't be "unrun". allowedit stops them on the next page load, and clears cookies it knows belong to that category where the browser allows it. For a clean state, reload the page after a visitor withdraws consent, using the JavaScript API.
Scripts added later by other scripts
Manual blocking applies to tags in your HTML. Scripts injected later by another script (a tag manager, an app, a widget) can't carry your attributes. For those:
- Use Google Tag Manager triggers on the
allowedit_consentevent, or - Add a custom URL rule in your dashboard. See Auto-blocking and custom rules.
Tips
- Put the allowedit script first. Blocking only works for tags that load after it.
- Don't block twice. If a script is in GTM with a consent trigger, you don't need to mark it too.
- Match the category to the cookie list. After a scan, check that the cookies a script sets are in the category you blocked it under, so the preferences panel tells visitors the truth.
- Test with Reject all. Open a private window, reject everything, and check the Network tab in your browser's developer tools: blocked URLs shouldn't be requested.
For background on why blocking matters, read How to block scripts until consent.
Still stuck? Email support@allowedit.com with your site's address and what you see.