Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions websites/confetti/src/cookie-consent.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ function initAdSense() {
return;
}

// Auto-ads are configured via the AdSense dashboard and activated automatically
// by the script when loaded with ?client=ca-pub-XXXXX — no manual push needed.
// Pushing enable_page_level_ads manually conflicts with the script's own init
// and causes "Only one 'enable_page_level_ads' allowed per page" TagError.
loadScript(
'adsense-script',
`https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=${ADSENSE_CLIENT_ID}`,
Expand All @@ -105,10 +109,6 @@ function initAdSense() {
);

window.adsbygoogle = window.adsbygoogle || [];
window.adsbygoogle.push({
google_ad_client: ADSENSE_CLIENT_ID,
enable_page_level_ads: true,
});

adsenseInitialized = true;
}
Expand All @@ -131,6 +131,7 @@ function initConsentDefaults() {
}

function updateConsentMode(activeConsent) {
initConsentDefaults();
ensureGtagStub();

window.gtag('consent', 'update', {
Expand Down
9 changes: 5 additions & 4 deletions websites/website/docs/.vitepress/theme/tracking/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ function initGoogleAdSense(): void {
return;
}

// Load the AdSense script with the client ID in the URL.
// Auto-ads are configured via the AdSense dashboard; the script enables them
// automatically when loaded with ?client=ca-pub-XXXXX — no manual push needed.
loadScriptOnce(
ADSENSE_SCRIPT_ID,
`https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=${trackingConfig.googleAdSenseClientId}`,
Expand All @@ -116,10 +119,6 @@ function initGoogleAdSense(): void {
}

trackingWindow.adsbygoogle ??= [];
trackingWindow.adsbygoogle.push({
google_ad_client: trackingConfig.googleAdSenseClientId,
enable_page_level_ads: true,
});

adSenseInitialized = true;
}
Expand All @@ -145,6 +144,8 @@ function updateConsentMode(preferences: CookieConsentPreferences): void {
return;
}

initConsentModeDefaults();

const trackingWindow = ensureGtagStub();

if (!trackingWindow?.gtag) {
Expand Down
Loading