Cookie banner for Astro
Comply with GDPR and Google Consent Mode v2 on your Astro site with a banner that really blocks scripts before consent and won't slow your site down.
Astro renders static HTML with interactive islands, but that same architecture makes a load-order mistake easy: if the CMP snippet doesn't have is:inline, Astro treats it as a module and defers it. The result is gtag.js or GTM can run before Consent Mode v2 defaults to «denied».
How to install it on Astro
- 1. Create your free account (Free plan, 1 site) at signup — no card required. Start free →
- 2. Open the dashboard, create your site and copy the snippet with your siteKey.
- 3. Paste the snippet with the is:inline attribute inside <head> in src/layouts/Layout.astro, as the first script — before GA4, GTM or any pixel.
- 4. Open the site in incognito, reject cookies and check in DevTools that there are no _ga / pixels before accept.
- 5. Done! The banner appears and Consent Mode v2 is active automatically. Need more sites or logs? Upgrade to Pro (€9/mo).
Using Google Tag Manager?
Import our official template and fire it with the "Consent Initialization" trigger.
⬇ Download GTM templateCommon mistakes with cookies on Astro
- ⚠️ Forgetting is:inline on the CMP script: Astro defers it and it loses load priority.
- ⚠️ Placing the snippet in an island component instead of the base layout (it won't run on every page).
- ⚠️ Loading GTM in <head> without first initializing Consent Mode defaults.
Why Consentio and not just any free plugin
- ✅ Real script blocking (most plugins don't do this).
- ✅ Full Google Consent Mode v2, with all 4 signals.
- ✅ Under 9 KB: it won't hurt your speed or your rankings.
- ✅ 6 languages and automatic visitor-country detection, included in every plan.
- ✅ Cookie scanner and automatic declaration ready for your policy.
- ✅ Auto-blocking of known trackers and consent records as proof in case of an audit.
Guides for other platforms
- Cookie banner for Svelte / SvelteKit
- Cookie banner for Laravel
- Cookie banner for Elementor
- Cookie banner for Google Sites
- Cookie banner for Nuxt
- Cookie banner for Hostinger