Last active
February 5, 2024 16:40
-
-
Save webtoffee-git/ec62d8e048d16d4e848482e81bb07217 to your computer and use it in GitHub Desktop.
Google consent mode compatibility - CookieYes | GDPR Cookie Consent Premium (https://www.webtoffee.com/product/gdpr-cookie-consent/)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // do not copy this line | |
add_action('wp_head', 'wt_cli_consent_mode_integration',9); | |
function wt_cli_consent_mode_integration() { | |
if (!class_exists('Cookie_Law_Info')) | |
return; | |
$cli_bypass = isset($_GET['cli_bypass']) ? 1 : 0; | |
?> | |
<script> | |
var wt_cli_ad_storage = 'denied'; | |
//set default value "denied" or "granted" | |
//for advertisement cookies storage | |
var wt_cli_analytics_storage = 'denied'; | |
//set default value "denied" or "granted" | |
//for analytics cookies storage | |
var wt_cli_ad_category = 'advertisement'; | |
//set slug of advertisement cookie category | |
var wt_cli_analytics_category = 'analytics'; | |
//set slug of analytics cookie category | |
var redact_ad_data = false; | |
// set "true" to increase the fidelity of advertising storage restrictions | |
var wt_cli_bypass = <?php echo $cli_bypass; ?>; | |
// for cookie scan support | |
if( wt_cli_bypass ) { | |
wt_cli_ad_storage = wt_cli_analytics_storage = 'granted'; | |
} | |
window.dataLayer = window.dataLayer || []; | |
function gtag(){dataLayer.push(arguments);} | |
gtag('consent', 'default', { | |
'ad_storage': wt_cli_ad_storage, | |
'analytics_storage': wt_cli_analytics_storage | |
}); | |
set_ads_data_redaction(); | |
function CookieLawInfo_Accept_Callback() { | |
wt_cli_ad_storage = 'denied'; | |
wt_cli_analytics_storage = 'denied'; | |
if(CLI.consent[wt_cli_ad_category] == true) { | |
wt_cli_ad_storage = 'granted'; | |
} | |
if(CLI.consent[wt_cli_analytics_category] == true) { | |
wt_cli_analytics_storage = 'granted'; | |
} | |
gtag('consent', 'update', { | |
'ad_storage': wt_cli_ad_storage, | |
'analytics_storage': wt_cli_analytics_storage | |
}); | |
set_ads_data_redaction(); | |
} | |
function set_ads_data_redaction() { | |
if(redact_ad_data && wt_cli_ad_storage == 'denied') { | |
gtag('set', 'ads_data_redaction', true); | |
} | |
} | |
</script> | |
<?php | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment