Last active
July 10, 2024 19:38
-
-
Save idokd/8fc18f8aab804f1b11f4104ff098da8d to your computer and use it in GitHub Desktop.
CookieYes Consent integration with HubSpot, PixelYourSite, Google 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
<script> | |
window.dataLayer = window.dataLayer || []; | |
window.gtag = window.gtag || function gtag() { | |
dataLayer.push( arguments ); | |
}; | |
var _cec = new Map( Cookies.get( 'cookieyes-consent' ) ? Cookies.get( 'cookieyes-consent' ).split( ',' ).map( a => a.split( ':' ) ) : [] ); | |
var _hsp = window._hsp = window._hsp || []; | |
if ( _cec.get( 'analytics' ) == 'no' ) { | |
_hsp.push( [ 'doNotTrack' ] ); | |
Cookies.set( '__hs_cookie_cat_pref', '1:false_2:false_3:false', { domain: '.drinkripples.com', expires: 180, path: '/' } ); | |
} else { | |
// _hsp.push( [ 'doNotTrack' , { track: true } ] );ֿ | |
Cookies.set( '__hs_cookie_cat_pref', '1:true_2:true_3:true', { domain: '.drinkripples.com', expires: 180, path: '/' } ); | |
} | |
function _consent_update( type, _cec ) { | |
gtag( 'consent', type, { | |
ad_storage: _cec.get( 'advertisement' ) == 'no' ? 'denied' : 'granted', | |
ad_user_data: _cec.get( 'advertisement' ) == 'no' ? 'denied' : 'granted', | |
ad_personalization: _cec.get( 'advertisement' ) == 'no' ? 'denied' : 'granted', | |
analytics_storage: _cec.get( 'analytics' ) == 'no' ? 'denied' : 'granted', | |
functionality_storage: _cec.get( 'functional' ) == 'no' ? 'denied' : 'granted', | |
personalization_storage: _cec.get( 'functional' ) == 'no' ? 'denied' : 'granted', | |
security_storage: _cec.get( 'necessary' ) == 'no' ? 'denied' : 'granted', | |
} ); | |
gtag( 'set', 'ads_data_redaction', true ); | |
gtag( 'set', 'url_passthrough', true ); | |
} | |
_consent_update( 'default', _cec ); | |
document.addEventListener( 'DOMContentLoaded', function() { | |
document.getElementsByClassName( 'cky-btn-revisit-button' )[0].addEventListener( 'click', function() { jQuery('.cky-btn-revisit-wrapper[data-cky-tag="revisit-consent"]' ).click(); } ); | |
}); | |
</script> | |
<!-- Google Tag Manager --> | |
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': | |
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], | |
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= | |
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); | |
})(window,document,'script','dataLayer','**********');</script> | |
<!-- End Google Tag Manager --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment