Getting Started
Up and running in 60 seconds.
Three steps. No build tools, no npm, no configuration files.
Create your account
Sign up at getconsent.io. Free plan includes 1 site and 5,000 pageviews per month.
Add your site
Go to the dashboard and add your domain. Choose a consent style and accent color.
Paste one script tag
Copy the snippet below into your HTML. That's it — you're compliant.
<script
src="https://getconsent.io/v1.js"
data-site="YOUR_SITE_KEY"
defer
></script>Replace YOUR_SITE_KEY with the key from your dashboard. The script is under 4kb gzipped, loads asynchronously, and causes zero layout shift.
Customization
Four ways to ask nicely.
Every site has a different tone. Pick the consent style that fits your brand, then customize the accent color from the dashboard.
Ghost
Best for: blogs, portfolios, minimal sites
Essential-only messaging by default. Displays a small shield badge in the corner that opens a preferences panel on click. Your site loads clean — no banner, no popup. The consent signal is still exposed so you can gate non-essential scripts.
Whisper
Best for: SaaS landing pages, marketing sites
A subtle bottom bar that slides in. Gives users a clear accept/decline choice without blocking content. Stays out of the way while remaining visible and accessible.
Trust Signal
Best for: e-commerce, finance, healthcare
A prominent but polished card overlay. Builds user confidence with clear language about what cookies are used and why. Ideal when trust is a key part of your conversion funnel.
Inline
Best for: sites requiring explicit consent before any interaction
A centered modal that requires interaction before the user can proceed. Impossible to miss. Use this when your legal team requires affirmative consent before the page becomes interactive.
All styles expose the same window.consentStatus property and consent event, so switching styles never requires code changes.
Core Concept
Gate scripts on consent.
The getconsent.io script exposes two primitives for controlling when third-party scripts execute:
- 1.
window.consentStatus— a string property that reflects the current state:"accept","reject", or"pending". - 2.A
consentCustomEvent dispatched onwindowwhenever the user makes or changes their choice. The event'sdetail.actioncontains the new status.
Basic pattern
Check the current status for returning visitors who already consented, then listen for new choices:
// Check current consent status (for returning visitors)
if (window.consentStatus === 'accept') {
loadAnalytics();
}
// Listen for new consent decisions
window.addEventListener('consent', function(e) {
if (e.detail.action === 'accept') {
loadAnalytics();
}
});Real-world example: Google Analytics
Gate Google Analytics so it only loads after the user accepts cookies. No data is sent to Google until explicit consent is given.
function loadGoogleAnalytics() {
var script = document.createElement('script');
script.src = 'https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX';
script.async = true;
document.head.appendChild(script);
script.onload = function() {
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', 'G-XXXXXXXXXX');
};
}
// Returning visitor who already consented
if (window.consentStatus === 'accept') {
loadGoogleAnalytics();
}
// First-time visitor — wait for consent
window.addEventListener('consent', function(e) {
if (e.detail.action === 'accept') {
loadGoogleAnalytics();
}
});Real-world example: Facebook Pixel
Same pattern, applied to the Facebook tracking pixel. The pixel only initializes after consent.
function loadFacebookPixel() {
!function(f,b,e,v,n,t,s) {
if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};
if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];
s.parentNode.insertBefore(t,s)
}(window,document,'script',
'https://connect.facebook.net/en_US/fbevents.js');
fbq('init', 'YOUR_PIXEL_ID');
fbq('track', 'PageView');
}
if (window.consentStatus === 'accept') {
loadFacebookPixel();
}
window.addEventListener('consent', function(e) {
if (e.detail.action === 'accept') {
loadFacebookPixel();
}
});Tip: handle rejection too
If you need to clean up when a user withdraws consent, listen for e.detail.action === 'reject' and remove any cookies or disable tracking accordingly.
Integration
Works with everything.
getconsent.io is a single script tag — it works anywhere HTML runs. Here are copy-paste examples for popular frameworks.
Next.js
App Router & Pages Router
Use the Next.js Script component to load the consent banner. Then gate analytics in a client component.
import Script from 'next/script';
export default function RootLayout({ children }) {
return (
<html lang="en">
<body>
{children}
<Script
src="https://getconsent.io/v1.js"
data-site="YOUR_SITE_KEY"
strategy="afterInteractive"
/>
</body>
</html>
);
}'use client';
import { useEffect } from 'react';
import Script from 'next/script';
import { useState } from 'react';
export function Analytics() {
const [consented, setConsented] = useState(false);
useEffect(() => {
if (window.consentStatus === 'accept') {
setConsented(true);
}
function onConsent(e: CustomEvent) {
setConsented(e.detail.action === 'accept');
}
window.addEventListener('consent', onConsent as EventListener);
return () => window.removeEventListener('consent', onConsent as EventListener);
}, []);
if (!consented) return null;
return (
<Script
src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"
strategy="afterInteractive"
/>
);
}React
Vite, Create React App, etc.
Add the script tag to your index.html, then use a useEffect hook to respond to consent changes.
import { useEffect, useState } from 'react';
export function useConsent() {
const [status, setStatus] = useState<string>(
() => (window as any).consentStatus ?? 'pending'
);
useEffect(() => {
function onConsent(e: CustomEvent) {
setStatus(e.detail.action);
}
window.addEventListener('consent', onConsent as EventListener);
return () => window.removeEventListener('consent', onConsent as EventListener);
}, []);
return status;
}
// Usage in any component:
// const consent = useConsent();
// if (consent === 'accept') { /* load analytics */ }WordPress
functions.php snippet
Add this to your theme's functions.php. It enqueues the consent script with the required data-site attribute.
function enqueue_getconsent_script() {
wp_enqueue_script(
'getconsent',
'https://getconsent.io/v1.js',
array(),
null,
array( 'strategy' => 'defer', 'in_footer' => true )
);
}
add_action( 'wp_enqueue_scripts', 'enqueue_getconsent_script' );
function add_getconsent_data_attribute( $tag, $handle ) {
if ( 'getconsent' !== $handle ) {
return $tag;
}
return str_replace(
' src',
' data-site="YOUR_SITE_KEY" src',
$tag
);
}
add_filter( 'script_loader_tag', 'add_getconsent_data_attribute', 10, 2 );Shopify
theme.liquid
Paste this into your theme's theme.liquid file, just before the closing </head> tag.
<!-- Add before </head> -->
<script
src="https://getconsent.io/v1.js"
data-site="YOUR_SITE_KEY"
defer
></script>Plain HTML
Any static site
Just add the script tag anywhere in your HTML. The defer attribute ensures it loads without blocking rendering.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>My Website</title>
<script
src="https://getconsent.io/v1.js"
data-site="YOUR_SITE_KEY"
defer
></script>
</head>
<body>
<!-- Your content -->
</body>
</html>Compliance
Link your privacy policy.
GDPR Article 13 requires that you inform users about your data processing practices at the point of collection. Your consent banner should link to a privacy policy that explains what cookies you use, why, and how users can manage their preferences.
In the getconsent.io dashboard, go to Site Settings → Privacy Policy URL and enter the full URL of your privacy policy page. The consent banner will automatically include a link to it.
What to include in your privacy policy:
- • Which cookies your site uses and their purpose
- • Which third parties receive data (Google Analytics, Facebook, etc.)
- • How long cookies persist
- • How users can withdraw consent at any time
- • Contact information for your Data Protection Officer (if applicable)
If you don't have a privacy policy yet, consult a legal professional familiar with the privacy regulations that apply to your users. getconsent.io helps you collect consent — but the policy itself should be written by someone who understands your specific data processing activities.
User Rights
Withdrawal is always available.
Under GDPR, users must be able to withdraw consent as easily as they gave it. getconsent.io handles this automatically with a persistent settings badge.
How it works:
- 1After a user makes their initial consent choice, the banner dismisses and a small shield badge appears in the corner of the screen.
- 2Clicking the badge reopens the consent preferences panel at any time.
- 3When a user changes their preference, a new
consentevent fires with the updated status. - 4The preference is stored locally and respected on subsequent visits. No server-side session is required.
If you're gating scripts with the event listener pattern described in Gating Scripts, withdrawal works automatically. When a user switches from accept to reject, the page reloads and your gated scripts simply won't execute on the next load.
Common Questions
Frequently asked.
Is getconsent.io GDPR compliant?+
Does getconsent.io block cookies?+
How does consent withdrawal work?+
What data does getconsent.io collect?+
Can I customize the consent banner?+
Does getconsent.io work with single-page applications?+
How do I integrate getconsent.io with Google Analytics?+
What's the difference between the consent styles?+
Is getconsent.io free?+
Does getconsent.io slow down my website?+
How does getconsent.io protect against abuse?+
Ready to get started?
Create a free account, add your site, and paste one script tag. You'll be compliant in under a minute.
Start free