Fix TCF bridge widget click for Google Funding Choices (v1.3.1)
FC accepts the IAB __tcfapi('displayConsentUi', 2, …) command without
throwing but silently no-ops, which caused the previous order (IAB first,
FC-specific fallback second) to swallow the click. Reorder so that
googlefc.showRevocationMessage() is tried first whenever window.googlefc
is present, with the IAB call kept as the fallback for non-FC CMPs
(Sourcepoint, Didomi, etc).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -103,15 +103,12 @@
|
||||
widget.addEventListener('click', function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
// 1. Standard IAB way (works for any compliant TCF v2.2 CMP).
|
||||
if (typeof window.__tcfapi === 'function') {
|
||||
try {
|
||||
window.__tcfapi('displayConsentUi', 2, function () {});
|
||||
return;
|
||||
} catch (err) {}
|
||||
// 1. Google Funding Choices: use its own re-prompt API.
|
||||
// FC accepts but silently ignores the IAB 'displayConsentUi'
|
||||
// command, so we must try the FC path FIRST when FC is detected.
|
||||
if (window.googlefc && typeof window.googlefc.showRevocationMessage === 'function') {
|
||||
try { window.googlefc.showRevocationMessage(); return; } catch (err) {}
|
||||
}
|
||||
|
||||
// 2. Google Funding Choices specific re-prompt.
|
||||
if (window.googlefc && window.googlefc.callbackQueue) {
|
||||
window.googlefc.callbackQueue.push({
|
||||
CONSENT_DATA_READY: function () {
|
||||
@@ -123,6 +120,12 @@
|
||||
return;
|
||||
}
|
||||
|
||||
// 2. Generic IAB TCF v2.2 re-prompt — for non-FC CMPs that
|
||||
// actually implement this (Sourcepoint, Didomi, etc.).
|
||||
if (typeof window.__tcfapi === 'function') {
|
||||
try { window.__tcfapi('displayConsentUi', 2, function () {}); return; } catch (err) {}
|
||||
}
|
||||
|
||||
// 3. Last-ditch: scroll to a #privacy / #cookies anchor if the
|
||||
// site has one in its footer. Fail silently otherwise.
|
||||
var fallback = document.querySelector('a[href*="#cookie"], a[href*="#privacy"]');
|
||||
|
||||
Reference in New Issue
Block a user