FitConsent Documentation
Everything you need to integrate, configure, and master consent management on your website.
What is a Consent Management Platform (CMP)?
A Consent Management Platform (CMP) is a tool that helps websites comply with data privacy regulations like GDPR, CCPA, and others. It informs users about what data is being collected, for what purpose, and allows them to give or withhold their consent for that data processing.
Essentially, a CMP is the bridge between your website's data collection activities and your users' right to privacy. FitConsent is a lightweight, powerful, and developer-friendly CMP designed to make this process seamless.
Integrating FitConsent is designed to be quick and straightforward. You only need to add a single script snippet to the <head> section of your website. This script handles everything from displaying the banner to managing Google Consent Mode defaults.
Important Prerequisite: Google Consent Mode v2
This is the simplest method. Copy the code below and paste it into the <head> section of your website's HTML. Remember to replace YOUR_WEBSITE_ID with the ID from your dashboard.
Loading...
Using Consent Data on Your Website
After a user interacts with the banner, FitConsent stores their choices and geolocation data in a cookie named `fitconsent_given`. You can read this cookie with JavaScript on the client-side or on the server-side with any backend language to tailor the user experience.
Cookie Structure
The cookie contains a JSON object with two main keys: `choices` and `geo`.
- choices: An object where keys are the consent categories (e.g., 'analytics', 'marketing') and values are boolean.
- geo: An object containing the user's location data (`country`, `state`, `city`).
Example Implementation
Here's how you can show a marketing banner only to users in California who have accepted marketing cookies.
function getFitConsentCookie() {
const name = 'fitconsent_given=';
const decodedCookie = decodeURIComponent(document.cookie);
const ca = decodedCookie.split(';');
for(let i = 0; i < ca.length; i++) {
let c = ca[i].trim();
if (c.indexOf(name) === 0) {
try {
return JSON.parse(c.substring(name.length, c.length));
} catch(e) {
return null;
}
}
}
return null;
}
const consentData = getFitConsentCookie();
if (consentData) {
const hasMarketingConsent = consentData.choices?.marketing === true;
const isCaliforniaUser = consentData.geo?.state === 'California';
if (hasMarketingConsent && isCaliforniaUser) {
// Assumes you have an element with this ID in your HTML
document.getElementById('california-offer-banner').style.display = 'block';
}
}
Language Detection Logic
To provide a seamless experience for a global audience, the FitConsent banner script automatically detects the appropriate language to use based on the following priority order:
- HTML `lang` Attribute: The script first checks the root `<html>` tag for a `lang` attribute (e.g., `<html lang=\"fr\">`). This is the most reliable method.
- Browser Settings: If the `lang` attribute is not found, the script falls back to the visitor's preferred browser language (`navigator.language`).
- Default Fallback: If neither method yields a configured language, the script defaults to English (`en`).