Open-source cookie banners with AdSense: what they can and cannot do
Key takeaways
- Popular open-source consent tools such as Klaro, CookieConsent by orestbida and tarteaucitron.js block scripts until consent, but they do not implement the IAB TCF API or write TC strings.
- None of them appears in Google's list of certified CMPs, which Google requires for personalized ads to users in the EEA, the UK and Switzerland.
- With an open-source banner and no TCF CMP, AdSense requests from those regions carry no TCF signal; Google reports error 10.1 and attempts limited ads.
- CookieConsent and tarteaucitron.js document Google consent mode support, which helps Google Analytics and Google Ads tags but is not what AdSense reads.
- A workable setup is Google's free European regulations message for ads, plus an open-source tool or your own code for non-Google scripts, with care to avoid two overlapping banners.

Open-source cookie banners such as Klaro, CookieConsent and tarteaucitron.js can block scripts until a visitor agrees, but none of them writes an IAB TCF consent string or appears on Google’s list of certified CMPs. For AdSense, that means EEA, UK and Swiss visitors cannot receive personalized ads through them. The usual fix is Google’s free certified message for ads, with an open-source tool only for other scripts.
This guide looks at the three tools as published on GitHub in November 2026. It describes product behavior and Google’s rules, not the law, and is not legal advice.
Why is a TCF string the dividing line?
AdSense does not read a generic “accepted” cookie. For European traffic it reads a TC string written by a CMP that implements the IAB TCF API (__tcfapi). Google’s publisher requirement adds a second condition: that CMP must be certified by Google for personalized ads in the EEA, the UK and Switzerland.
| What your banner produces | What AdSense sees | Best serving mode in EEA, UK, CH |
|---|---|---|
| TC string from a Google-certified CMP | Full consent signal | Personalized, NPA or limited, per user choice |
| TC string from a non-certified CMP | Signal from an unknown CMP (error 9.1) | Non-personalized at best |
| No TC string (any non-TCF banner) | No TCF signal (error 10.1) | Limited ads, if enabled |
| Banner blocks the AdSense script until “Accept” | Nothing for refusers; no TCF signal for accepters | Limited ads for accepters, no ads for refusers |
Error codes are from Google’s TCF troubleshooting article. The certified CMP guide explains the list and its weekly updates.
How do the three main open-source tools compare?
| Klaro | CookieConsent (orestbida) | tarteaucitron.js | |
|---|---|---|---|
| Licence | BSD-3-Clause | MIT | MIT |
| Latest release seen | Repository last updated March 2025 | v3.3.0 (November 2026) | v1.37.0 (October 2026) |
| Script blocking | Yes, third-party apps run only after consent | Yes, by category | Yes, per service |
| Google consent mode | Not documented in the readme | Documented integration example | Built in ("googleConsentMode": true) |
| AdSense-specific handling | None built in | None built in | Services “adsense”, “adsenseauto”, “adsensesearch” |
| IAB TCF API / TC string | No | No | No |
| On Google’s certified CMP list | No | No | No |
Klaro
The Klaro repository (the old klaro-org/klaro-js address redirects there) describes it as “a simple consent management platform (CMP)” that ensures “no third-party apps or trackers are executed without the consent of the user”. You can reopen it with klaro.show(). The readme does not mention TCF support.
CookieConsent by orestbida
CookieConsent is a lightweight, MIT-licensed banner organized by categories. Its documentation includes a Google consent mode page showing how to map categories to gtag('consent', 'update', ...). That covers Google Analytics and Google Ads tags. As the consent mode guide explains, AdSense does not read consent mode.
tarteaucitron.js
tarteaucitron.js ships a service catalog. Its “adsense” service is marked "needConsent": true and adds adsbygoogle.js only after the user accepts. Its “adsenseauto” variant loads the Auto ads script with your publisher ID. This is a clean way to keep AdSense cookies off refusing browsers, but AdSense still receives no TC string from accepting ones.
What setups actually work with AdSense?
| Setup | Personalized ads in EEA/UK/CH | Blocks non-Google scripts | Cost |
|---|---|---|---|
| Google’s European regulations message only | Yes | No | Free |
| Google’s message for ads plus an open-source tool for other scripts | Yes | Yes | Free, more setup |
| Certified commercial CMP | Yes | Usually yes | Usually paid |
| Open-source banner only | No (limited ads at best) | Yes | Free |
The hybrid row needs care. Visitors should not face two banners asking overlapping questions. Two ways to handle it:
- Let Google’s message ask, and gate other scripts on its signal. Read the TC string with
__tcfapi('addEventListener', 2, callback)and load analytics or embeds only when the purposes you need are granted. Google’s European regulations message can also send consent mode signals to Google Analytics directly (see the Privacy & messaging guide). - Avoid the need. If your only non-Google scripts are self-hosted, cookieless analytics, a second banner may be unnecessary. Check with your adviser; see open-source analytics next to AdSense.
How do you gate other scripts on Google’s TCF signal?
The IAB’s CMP API specification requires every TCF CMP, Google’s included, to support addEventListener. The callback receives a TCData object with an eventStatus and, per purpose, a purpose.consents map where true means consent. A minimal pattern:
<script>
function loadAnalytics() {
// Insert your analytics or embed script here.
}
window.__tcfapi && __tcfapi('addEventListener', 2, function (tcData, success) {
if (!success) return;
var ready = tcData.eventStatus === 'tcloaded' ||
tcData.eventStatus === 'useractioncomplete';
if (!ready) return;
if (tcData.gdprApplies === false) { loadAnalytics(); return; }
if (tcData.purpose.consents[1] && tcData.purpose.consents[8]) {
loadAnalytics();
}
});
</script>
The specification defines tcloaded as the state when a valid TC string exists and no UI will be shown, and useractioncomplete as the state after the user confirms choices. Which purposes a non-Google script needs is your decision: the example checks Purpose 1 (storing or accessing information on a device) and Purpose 8 (measuring content performance) for an analytics tool, which is one reasonable reading, not a rule.
Three points to check before relying on this:
- Load order. The
__tcfapifunction exists only after the CMP stub runs. If your script runs first, queue it until the stub is available. - Visitors outside Europe. Google’s message only appears in the regions you target. Where
gdprAppliesis false, decide separately whether the script loads. - Withdrawal. The callback fires again when the TC string changes. If a visitor withdraws consent, stop the script or reload the page so it no longer runs.
Which setup fits your site?
| Your situation | Suggested setup | Why |
|---|---|---|
| AdSense only, no other trackers | Google’s European regulations message | One certified banner, no extra code |
| AdSense plus Google Analytics | Google’s message with consent mode enabled | One banner feeds both TCF and consent mode |
| AdSense plus non-Google embeds or trackers | Google’s message, gate other scripts on the TC string | One banner, one source of truth |
| No AdSense in Europe, analytics and embeds only | Any of the three open-source tools | Certification is not needed outside Google’s requirement |
| Large site with many vendors and legal review | Certified commercial CMP | Vendor management, reporting and support |
When is an open-source banner enough?
- No visitors from the EEA, the UK or Switzerland. Google’s certified CMP requirement only applies to requests from those regions.
- You accept limited ads in Europe. Some small sites prefer one simple banner and contextual-only ads for European visitors. Limited ads must stay on, and earnings from that traffic will drop.
- You do not run AdSense on every page. For a blog section without ads, a lightweight banner can manage analytics and embeds.
Common mistakes
- Assuming “GDPR compliant” in a readme means “AdSense compatible”. Compliance claims are about the law; AdSense needs a certified TCF CMP.
- Blocking AdSense entirely for refusers and turning off limited ads. That gives no revenue from a large share of European visitors.
- Running an open-source banner and Google’s message together without coordination. Users see two prompts, and choices can contradict each other.
- Mapping the banner to consent mode and expecting AdSense to follow. It will not.
- Forgetting to update. Banners pinned to old versions miss fixes; check release notes.
Open-source tools mentioned
| Tool | Licence |
|---|---|
| Klaro | BSD-3-Clause |
| CookieConsent (orestbida) | MIT |
| tarteaucitron.js | MIT |
Frequently asked questions
Can I show AdSense ads in Europe with only an open-source cookie banner?
Ads can still serve, but not personalized ones. Without a TC string from a Google-certified CMP, Google treats EEA, UK and Swiss requests as having no TCF signal (error 10.1) and attempts limited ads, if limited ads are enabled. If you turned limited ads off, those visitors may see no ads at all.
Could I add TCF support to an open-source banner myself?
Technically you could implement the TCF CMP API, but a CMP must be registered with IAB Europe and receive a CMP ID, and Google must then certify it before its strings unlock personalized ads. Google's list includes private in-house CMPs run by large publishers, which shows the route exists, but it is a compliance project, not a plugin setting.
Is tarteaucitron.js's AdSense service enough for GDPR?
It loads the AdSense script only after the user accepts the ads service, which handles the storage question for consenting and refusing users in a simple way. It does not produce a TC string, so AdSense cannot tell the consent level, and Google's certified CMP requirement for personalized ads in Europe is not met.
Which open-source tool fits a site without European traffic?
If none of your audience is in the EEA, the UK or Switzerland, Google's certified CMP requirement has no practical effect, and any of the three tools can manage analytics and embed consent. For US visitors, remember that state laws work with opt-outs and Global Privacy Control rather than opt-in banners.
Sources
- Google consent management requirements for serving ads in the EEA, the UK, and Switzerland (for publishers) · Google AdSense Help
- Troubleshooting IAB EU TCF v2.3 implementation · Google AdSense Help
- kiprotect/klaro · GitHub
- orestbida/cookieconsent · GitHub
- AmauriC/tarteaucitron.js · GitHub
- Google consent mode (CookieConsent documentation) · CookieConsent
Related guides
- Google's certified CMP requirement: what AdSense publishers need for EEA, UK and Swiss traffic
Since 2024 AdSense needs a Google-certified TCF CMP for personalized ads in the EEA, UK and Switzerland. Dates, what happens without one, how to check yours.
- AdSense Privacy & messaging: building the European regulations (GDPR) message
Build the GDPR consent message in AdSense Privacy & messaging: every setting, the two- vs three-button layout, testing, troubleshooting and what it cannot do.
- Consent mode v2 and AdSense: two consent signals, one site
Google consent mode v2 explained for AdSense sites: why AdSense reads the TCF string, not consent mode, and how to keep Analytics and AdSense signals aligned.
- IAB TCF v2.3 for publishers: what Google requires, what changed from v2.2, and v2.4
TCF v2.3 is mandatory for TC strings created since March 1, 2026. What changed from v2.2, Google's dates, the purposes AdSense needs, and the v2.4 update.
- Personalized, non-personalized and limited ads: the three AdSense serving modes compared
How AdSense picks personalized, non-personalized or limited ads from consent signals, what each mode still collects, the ad code switches and the setting to check.