### Configure Usercentrics CMP with Setting-ID Source: https://context7.com/usercentrics/gtm-templates-usercentrics-cmp/llms.txt Use this JSON configuration when a single global Usercentrics CMP setup is desired. Ensure the 'data-settings-id' field contains your unique Setting-ID. ```json { "id-selection": "settingsId", "data-settings-id": "ABC123xyz" } ``` -------------------------------- ### Configure Usercentrics CMP with Ruleset-ID Source: https://context7.com/usercentrics/gtm-templates-usercentrics-cmp/llms.txt Use this JSON configuration for geolocation-based Usercentrics CMP setups. The 'data-ruleset-id' field should contain your Ruleset-ID, allowing different CMPs per region. ```json { "id-selection": "rulesetId", "data-ruleset-id": "Q1pG5j-W5pgWef" } ``` -------------------------------- ### Pre-populate Consent from localStorage (`uc_gcm`) Source: https://context7.com/usercentrics/gtm-templates-usercentrics-cmp/llms.txt Before the CMP loads, the template reads the `uc_gcm` key from `localStorage` to restore previous consent, preventing flickering by calling `updateConsentState` with stored values. ```javascript // Template reads stored consent on every page load BEFORE injecting CMP const ucGcmString = localStorage.getItem('uc_gcm'); if (ucGcmString) { const ucGcmData = JSON.parse(ucGcmString); // ucGcmData shape: { adStorage, analyticsStorage, adPersonalization, adUserData } if (ucGcmData.adStorage && ucGcmData.analyticsStorage && ucGcmData.adPersonalization && ucGcmData.adUserData) { updateConsentState({ ad_storage: ucGcmData.adStorage, ad_personalization: ucGcmData.adPersonalization, ad_user_data: ucGcmData.adUserData, analytics_storage: ucGcmData.analyticsStorage }); } } ``` -------------------------------- ### Enable AMP Support for Legacy Banner Source: https://context7.com/usercentrics/gtm-templates-usercentrics-cmp/llms.txt Activate AMP compatibility mode for the legacy browser-UI banner by setting 'window.ampEnabled = true' before script injection. ```json { "data-amp-enabled": true, "data-banner-version": "browser-ui" } ``` -------------------------------- ### Enable URL Passthrough Source: https://context7.com/usercentrics/gtm-templates-usercentrics-cmp/llms.txt Enabling `urlPassthrough` appends consent state information as query parameters to outbound links, facilitating cross-domain measurement without third-party cookies. ```json { "consentModeEnabled": true, "urlPassthrough": true } ``` -------------------------------- ### Inject V3 Banner Scripts Source: https://context7.com/usercentrics/gtm-templates-usercentrics-cmp/llms.txt Use this snippet for the V3 banner mode. It configures the `ucCmpGTMConfig` object and injects the TCF stub and main V3 loader scripts. ```javascript // V3 runtime execution path const ucCmpGTMConfig = {}; ucCmpGTMConfig['settingsId'] = 'ABC123xyz'; // or rulesetId ucCmpGTMConfig['language'] = 'en'; ncCmpGTMConfig['disableGcmDefaults'] = true; // template manages defaults itself // ucCmpGTMConfig['advertiserConsentMode'] = true; // if TCF + advertiser mode enabled setInWindow('ucCmpGTMConfig', ucCmpGTMConfig); // TCF stub injected first when TCF is enabled injectScript( 'https://web.cmp.usercentrics.eu/tcf/stub.js', data.gtmOnSuccess, data.gtmOnFailure ); // Main V3 CMP loader injectScript( 'https://web.cmp.usercentrics.eu/ui/loader.js', data.gtmOnSuccess, data.gtmOnFailure ); ``` -------------------------------- ### Configure Per-Region Default Consent States Source: https://context7.com/usercentrics/gtm-templates-usercentrics-cmp/llms.txt Use `regionSettings` to define different default consent states for specific geographic regions. An empty region string acts as a global fallback. ```javascript // GTM template data – set stricter defaults for EU regions, lenient for US const regionSettings = [ { region: "DE, AT, CH", // DACH region defaultConsentPreferences: "denied", defaultConsentStatistics: "denied", defaultConsentMarketing: "denied", defaultAdPersonalization: "denied", defaultAdUserData: "denied" }, { region: "", // Global fallback defaultConsentPreferences: "granted", defaultConsentStatistics: "granted", defaultConsentMarketing: "denied", defaultAdPersonalization: "denied", defaultAdUserData: "denied" } ]; ``` ```javascript // Resulting gtag calls produced by the template: setDefaultConsentState({ region: ["DE", "AT", "CH"], ad_storage: "denied", ad_personalization: "denied", ad_user_data: "denied", analytics_storage: "denied", functionality_storage: "denied", personalization_storage: "denied", wait_for_update: 500 // ms to wait before firing tags }); ``` ```javascript setDefaultConsentState({ ad_storage: "denied", ad_personalization: "denied", ad_user_data: "denied", analytics_storage: "granted", functionality_storage: "granted", personalization_storage: "granted", security_storage: "granted" }); ``` -------------------------------- ### Select Usercentrics CMP Banner Version (V3) Source: https://context7.com/usercentrics/gtm-templates-usercentrics-cmp/llms.txt Configure the template to use the recommended V3 CMP banner. This version loads from 'https://web.cmp.usercentrics.eu/ui/loader.js'. ```json { "data-banner-version": "V3" } ``` -------------------------------- ### Inject Legacy Banner Scripts Source: https://context7.com/usercentrics/gtm-templates-usercentrics-cmp/llms.txt This snippet is for the legacy browser-UI banner. It sets individual `window` globals and injects the legacy loader URL. ```javascript // Legacy runtime execution path setInWindow('settingsId', 'ABC123xyz'); // or rulesetId setInWindow('language', 'en'); setInWindow('tcfEnabled', true); // if TCF enabled setInWindow('ampEnabled', true); // if AMP enabled setInWindow('disableGcmDefaults', true); // suppress CMP's own GCM defaults setInWindow('advertiserConsentMode', true); // if TCF + advertiser mode injectScript( 'https://app.usercentrics.eu/browser-ui/latest/loader.js', data.gtmOnSuccess, data.gtmOnFailure ); ``` -------------------------------- ### Select Usercentrics CMP Banner Version (Legacy) Source: https://context7.com/usercentrics/gtm-templates-usercentrics-cmp/llms.txt Configure the template to use the legacy browser-UI CMP banner. This version loads from 'https://app.usercentrics.eu/browser-ui/latest/loader.js'. ```json { "data-banner-version": "browser-ui" } ``` -------------------------------- ### Configure Google Consent Mode v2 Defaults Source: https://context7.com/usercentrics/gtm-templates-usercentrics-cmp/llms.txt Sets default consent states for various categories, applies 'developer_id', and configures URL passthrough and ads data redaction when Google Consent Mode is enabled. Note that 'security_storage' is always granted. ```javascript gtagSet('developer_id.dOThhZD', true); gtagSet({ 'url_passthrough': true, 'ads_data_redaction': true }); setDefaultConsentState({ ad_storage: 'denied', ad_user_data: 'denied', ad_personalization: 'denied', analytics_storage: 'denied', functionality_storage: 'denied', personalization_storage: 'denied', security_storage: 'granted' }); ``` -------------------------------- ### Configure Wait for Update Delay Source: https://context7.com/usercentrics/gtm-templates-usercentrics-cmp/llms.txt The `waitForUpdate` setting in Consent Mode determines the delay in milliseconds before firing dependent tags, ensuring the CMP has signaled consent. This requires a non-negative number. ```json { "consentModeEnabled": true, "waitForUpdate": 500 } ``` -------------------------------- ### Enable TCF 2.2 Support with V3 Banner Source: https://context7.com/usercentrics/gtm-templates-usercentrics-cmp/llms.txt Enable IAB Europe's Transparency & Consent Framework. When used with the V3 banner, the TCF stub script is injected first for immediate consent signal delivery to TCF-aware tags. ```json { "data-tcf-enabled": true, "data-banner-version": "V3" } ``` -------------------------------- ### Configure Advertiser Consent Mode (TCF) Source: https://context7.com/usercentrics/gtm-templates-usercentrics-cmp/llms.txt When TCF is enabled, `advertiserConsentMode` instructs Google to derive consent signals directly from the TCF CMP string, bypassing explicit gtag consent calls. ```javascript // Effective behavior (V3 path) ucCmpGTMConfig['advertiserConsentMode'] = true; setInWindow('ucCmpGTMConfig', ucCmpGTMConfig); // Legacy browser-UI path setInWindow('advertiserConsentMode', true); ``` -------------------------------- ### Configure Ads Data Redaction Source: https://context7.com/usercentrics/gtm-templates-usercentrics-cmp/llms.txt The `adsDataRedaction` setting controls the redaction of ad click identifiers when marketing consent is denied. 'dynamic' mode reads prior consent from `localStorage` for runtime decisions. ```javascript // Dynamic mode: reads previously stored consent from localStorage const ucGcmString = localStorage.getItem('uc_gcm'); const ucGcmData = JSON.parse(ucGcmString); // If ad_storage was previously granted, disable redaction if (ucGcmData.adStorage === 'granted') { adsDataRedactionValue = false; // user already consented } else { adsDataRedactionValue = true; // default: redact } gtagSet({ 'ads_data_redaction': adsDataRedactionValue }); ``` -------------------------------- ### Set Usercentrics CMP Default Language Source: https://context7.com/usercentrics/gtm-templates-usercentrics-cmp/llms.txt Optionally set the CMP's display language using a BCP 47 / ISO 639-1 code. If omitted, the CMP auto-detects the language from the browser. ```json { "data-language": "de" } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.